This is a migrated thread and some comments may be shown as answers.

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

3 Answers 38 Views
OQL (OQL specific questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Paul
Top achievements
Rank 1
Paul asked on 04 Jun 2009, 08:42 AM
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

3 Answers, 1 is accepted

Sort by
0
Thomas
Telerik team
answered on 04 Jun 2009, 03:01 PM
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.
0
Paul
Top achievements
Rank 1
answered on 04 Jun 2009, 05:12 PM

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.
0
Thomas
Telerik team
answered on 05 Jun 2009, 08:33 AM
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.
Tags
OQL (OQL specific questions)
Asked by
Paul
Top achievements
Rank 1
Answers by
Thomas
Telerik team
Paul
Top achievements
Rank 1
Share this question
or