| criteria API: select count(*) from .. [message #487130] |
Tue, 22 September 2009 01:27  |
Serge Messages: 76 Registered: July 2009 |
Member |
|
|
Is it correct usage?
EntityManager em = getEntityManager();
try {
QueryBuilder qb = em.getQueryBuilder();
CriteriaQuery cq = qb.createQuery();
Root<DiscountCode> dc = cq.from(DiscountCode.class);
cq.select(qb.count(dc));
Query q = em.createQuery(cq);
return ((Long) q.getSingleResult()).intValue();
} finally {
em.close();
}
if yes, then I got two issues here in eclipselink 2.0 M7, return value
is double (may be known issue
https://bugs.eclipse.org/bugs/show_bug.cgi?id=289830)
and value is powered in two, i.e. if I have 6 rows result will be 36.0,
after addition of one more row I have result 49.0, it may be somehow
related to issue https://bugs.eclipse.org/bugs/show_bug.cgi?id=245653
but may be another one.
|
|
|
| Re: criteria API: select count(*) from .. [message #487815 is a reply to message #487130] |
Thu, 24 September 2009 09:47   |
James Sutherland Messages: 1844 Registered: July 2009 |
Senior Member |
|
|
The first issue seems to be the same as the logged bug. Please try again on the next good 2.0 build.
The second issue does not seem related. It seems that it is joining the DiscountCode twice for some reason. Please include the SQL generated. If you use the dc variable in the where clause, does the extra join still occur? Either way it seems like a bug, maybe retry in the latest build, and if it still occurs log the bug.
James : Wiki : Book : Blog
|
|
|
|
|
|
|
| Re: criteria API: select count(*) from .. [message #488000 is a reply to message #487894] |
Fri, 25 September 2009 05:18  |
Serge Messages: 76 Registered: July 2009 |
Member |
|
|
Serge пишет:
> Serge пишет:
>> Serge пишет:
>>
>>> ok, I can try, where I can find dayly builds of el 2.0?
>>
>>
>> found nightly myself, will try
>
> looks fixed in 090921, will reverify tomorrow
and 090925 have both issues fixed, thanks
|
|
|
Powered by
FUDForum. Page generated in 0.01734 seconds