criteria API: select count(*) from .. [message #487130] |
Tue, 22 September 2009 05:27  |
Eclipse User |
|
|
|
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 13:47   |
Eclipse User |
|
|
|
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.
|
|
|
Re: criteria API: select count(*) from .. [message #487885 is a reply to message #487815] |
Thu, 24 September 2009 17:01   |
Eclipse User |
|
|
|
James пишет:
> 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.
>
>
ok, I can try, where I can find dayly builds of el 2.0?
second one issue generate multiplied by itself results if count if used,
and generate expected result(except type) if countDistinct is used.
|
|
|
|
|
|
Re: criteria API: select count(*) from .. [message #488000 is a reply to message #487894] |
Fri, 25 September 2009 09:18  |
Eclipse User |
|
|
|
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.02956 seconds