line 1:10: Field "licenseFile" is not a reference or simple type

4 posts, 0 answers
  1. Paul
    Paul avatar
    113 posts
    Member since:
    May 2009

    Posted 04 Jun 2009 Link to this post

    Hi,
       Using OQL I am unable to return longblob field from my MySQL DB. The same thing happens in code as well as using your OQL query browser.

    If use this statement

    SELECT p.licenseFile FROM LicenseExtent AS p WHERE p.licenseID = 1

    I get this error:

    line 1:10: Field "licenseFile " is not a reference or simple type. {licenseFile ["licenseFile ",<42>,line=1,col=10]}

    SELECT p.~~~licenseFile FROM LicenseExtent AS p WHERE p.licenseID = 1

     

     

    If I do this
    SELECT * FROM LicenseExtent AS p WHERE p.licenseID = 1

    Then the data is returned without error but of course I get extra columns I don't want. Interesting thing is that for this statement the sql generated string is

    SELECT `licenseID ` AS COL1 FROM `license` WHERE `licenseID ` = 1
    but the result window does show the licensefile column.

    The same thing happens on any table when I just try to retrieve the one column of type longblob.

    Is this a bug or am I missing something?
    Thanks

  2. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 04 Jun 2009 Link to this post

    Hi Paul,

    I think what happens is that it is not supported to have such a blob projected in an OQL query. When you use select * from ... then the default fetch group is loaded (which does not contain the blob) but when you trigger the lazy loading is is loaded; that's why you see it in the results window.

    So the best way to do this is to use either OQL or GetObjectById to locate the instance and then access the blob field so that the lazy loading mechanism can do it's job. It will generate the correct statements and just load the blob field as the blob should not be in the default fetch group but in it's own.

    Best wishes,
    Thomas
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. DevCraft banner
  4. Paul
    Paul avatar
    113 posts
    Member since:
    May 2009

    Posted 04 Jun 2009 Link to this post

    Hi,
       Could you provide me an example on how to do what you are saying as I thought I was using OQL.

    I have a function in my DataAccess layer that I just want to send a OQL string query to as the string in my last post. The table and return column can differ so I don't want table or column specific code in the function.

        public byte[] GetByteArrayQuery(String MyQuery)  
            {  
     
                IQuery q;  
                byte[] MyRetVal = new byte[0];  
                Telerik.OpenAccess.IObjectScope scope = GetMyOS();  
                q = scope.GetOqlQuery(MyQuery);  
                  
                Telerik.OpenAccess.IQueryResult qr = q.Execute();  
     
                if (qr.Count == 0)  
                {  
     
                    return MyRetVal;  
                }  
                else if (qr[0] == null)  
                {  
                    return MyRetVal;  
                }  
                MyRetVal = (byte[])qr[0];  
                return MyRetVal;  
     
     
     
            } 
    Is this something that can be achieved.
  5. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 05 Jun 2009 Link to this post

    Hi Paul,

    you should use something similiar to:

    IQuery q = scope.GetOqlQuery("select p from LicenseExtent as p where p.ID = $1"); 
    using(IQueryResult res = q.Execute("myIdValue")) 
        License p = (License) res[0]; 
        return p.licenseFile; 
    }

    This will load one instance with no additional fields and then when the licenseFile field is accessed (which should really be wrapped into a property!) the content is loaded on demand.

    Regards,
    Thomas
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top