cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: EJBQL weirdness
Date Tue, 06 Sep 2016 07:10:32 GMT
I don't have an explanation.. Were you able to find anything?

Andrus 

> On Aug 30, 2016, at 2:35 PM, Hugi Thordarson <hugi@karlmenn.is> wrote:
> 
> Hi all.
> I’m encountering some weirdness when running EJBQLQuery. Consider the following code:
> 
> 	EJBQLQuery q = new EJBQLQuery( "select i.unitPrice,i.quantity from InvoiceLine i where
i.companyNumber='0100008338'" );
> 	List fetchedRows = objectContext.performQuery( q );
> 	System.out.println( "Size of resulting list: " + fetchedRows.size() );
> 	System.out.println( "Class of fetched objects: " + fetchedRows.get( 0 ).getClass() );
> 
> This generates the following output:
> 
> 	- --- transaction started.
> 	- SELECT t0.unit_price AS sc0, t0.quantity AS sc1 FROM bok_invoice_line t0 WHERE t0.company
= ? [bind: 1:'0100008338']
> 	- === returned 508 rows. - took 72 ms.
> 	- +++ transaction committed.
> 	Size of resulting list: 200
> 	Class of fetched objects: class [Ljava.lang.Object;
> 
> As you can see, the SQL is correct, and the debug log shows that the DB returns the expected
number of 508 objects. However, the resulting List will only contain 200 objects. This number
will then go on to change in weird ways if I modify the query, for example if I add a third
attribute to fetch, the List will suddenly contain 204 objects—and that number may change
based on which attribute I added. Quite odd, and I’ve not been able to identify any rule
to how it happens.
> 
> Now, for the second level of weirdness: If I change the query to fetch data rows (by
invoking setFetchingDataRows( true )), the list will end up containing the correct number
of rows. But they will still be Object[] but not DataRows.
> 
> 	- --- transaction started.
> 	- SELECT t0.unit_price AS sc0, t0.quantity AS sc1 FROM bok_invoice_line t0 WHERE t0.company
= ? [bind: 1:'0100008338']
> 	- === returned 508 rows. - took 64 ms.
> 	- +++ transaction committed.
> 	Size of resulting list: 508
> 	Class of fetched objects: class [Ljava.lang.Object;
> 
> Any idea what’s happening? Thought I’d ask before I start digging around.
> 
> Cheers,
> - hugi


Mime
View raw message