Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » criteria API: select count(*) from ..
criteria API: select count(*) from .. [message #487130] Tue, 22 September 2009 05:27 Go to next message
Serge  is currently offline 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 13:47 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
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 : Twitter
Re: criteria API: select count(*) from .. [message #487885 is a reply to message #487815] Thu, 24 September 2009 17:01 Go to previous messageGo to next message
Serge  is currently offline Serge
Messages: 76
Registered: July 2009
Member
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 #487887 is a reply to message #487815] Thu, 24 September 2009 17:06 Go to previous messageGo to next message
Serge  is currently offline Serge
Messages: 76
Registered: July 2009
Member
James пишет:
> Please include the SQL generated.
> If you use the dc variable in the where clause, does the extra join
> still occur?

one more, how I can find what sql is generated?
will try a bit later
Re: criteria API: select count(*) from .. [message #487888 is a reply to message #487885] Thu, 24 September 2009 17:09 Go to previous messageGo to next message
Serge  is currently offline Serge
Messages: 76
Registered: July 2009
Member
Serge пишет:

> ok, I can try, where I can find dayly builds of el 2.0?


found nightly myself, will try
Re: criteria API: select count(*) from .. [message #487894 is a reply to message #487888] Thu, 24 September 2009 17:55 Go to previous messageGo to next message
Serge  is currently offline Serge
Messages: 76
Registered: July 2009
Member
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
Re: criteria API: select count(*) from .. [message #488000 is a reply to message #487894] Fri, 25 September 2009 09:18 Go to previous message
Serge  is currently offline 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
Previous Topic:Inheritance problem with Id in subclass
Next Topic:Unknown entity type
Goto Forum:
  


Current Time: Tue Sep 23 14:42:03 GMT 2014

Powered by FUDForum. Page generated in 0.04580 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software