kundera icon indicating copy to clipboard operation
kundera copied to clipboard

How can i get count() result by using jpql !

Open zhouhero opened this issue 13 years ago • 18 comments

I can not get result by EntityManager.getSingleResult() My jpql is that:

"select count(c.id) from Test1Entity "

Can anyone help me!

zhouhero avatar Dec 14 '12 00:12 zhouhero

Aggregate functions are not supported.

-Vivek

mevivs avatar Dec 14 '12 02:12 mevivs

Thanks for your response. when paging, i need get the total records nums.... we are using cassandra 1.2 now..

so, can you implement it for me in 2.3. Thank you very mutch!!!!!!

zhouhero avatar Dec 14 '12 05:12 zhouhero

I will try to get this working in 2.3 release.

-Vivek

Thank you very much! I am looking forward to it.......

zhouhero avatar Dec 14 '12 12:12 zhouhero

Support added on latest trunk, will be released with 2.3

-Vivek

mevivs avatar Jan 22 '13 09:01 mevivs

thank you very much! i will try it in the new version.

zhouhero avatar Jan 22 '13 09:01 zhouhero

sorry, can you give me a sample to do count by jpql?

zhouhero avatar Jan 29 '13 11:01 zhouhero

it seem that getSingleResult() is not implemented in kundera2.3

zhouhero avatar Jan 29 '13 11:01 zhouhero

Here is a test case: https://github.com/impetus-opensource/Kundera/blob/trunk/kundera-cassandra/src/test/java/com/impetus/client/crud/PersonCassandraTest.java

Method: getCountResult().

As discussed on some other issue thread as well, getSingleResult() will be in future releases. But support for count queries is enabled in 2.3

mevivs avatar Jan 29 '13 14:01 mevivs

thanks for your sample! it seems that count can be done by CQL now.

by the way, can i do count by using jpql like "select count(c) from Test1 c " by using excuteQuery()?

zhouhero avatar Jan 30 '13 00:01 zhouhero

Hi Zhouhero,

Native queries in Kundera are passed to database "as it is" and they are run by query language interpreter (or whatever mechanism) provided within datastore.

Since CQL allows only * or 1 in count function, you can run native queries in below two formats only:

  1. select count(*) from tableName;
  2. select count(1) from tableName;

Thanks Kuldeep

On Wed, Jan 30, 2013 at 6:01 AM, zhouhero [email protected] wrote:

thanks for your sample! it seems that count can be done by CQL now.

by the way, can i do count by using jpql like "select count(c) from Test1 c " by using excuteQuery()?

— Reply to this email directly or view it on GitHubhttps://github.com/impetus-opensource/Kundera/issues/150#issuecomment-12867262.

Thanks and Regards Kuldeep Kumar Mishra +919540965199

kkmishra avatar Jan 30 '13 07:01 kkmishra

thanks for you explanations. but what i say is using JPQL not CQL. when using JPQL how can i do it?

zhouhero avatar Jan 31 '13 09:01 zhouhero

Will try to assess it for 2.4. As change in JPQL will require more assessment with other databases as well. Even with JPQL, it will get converted into CQL. So i guess it should not much difference in terms of usage. Is there anything you not able achieve via CQL and looking forward to be done with JPQL?

-Vivek

mevivs avatar Jan 31 '13 09:01 mevivs

we are using JPQL now, as you know, there are many problems in using CQL(CQLSH) and Shrift at the same time. so we want using Shrift only. if we using JPQL an set the driver to Shrift, we can do well by Shrift withe kundera, i think so.

zhouhero avatar Jan 31 '13 11:01 zhouhero

Well, i guess using CqL for count() should not be any problem with Kundera. It is executed via Thrift only!

-Vivek

mevivs avatar Jan 31 '13 11:01 mevivs

As you know , there are many meta infomations' problems in thrift cql api . Pls refer to: https://github.com/impetus-opensource/Kundera/issues/170

zhouhero avatar Feb 01 '13 00:02 zhouhero

"select count(c.id) from Test1Entity c" i s can be used now in kunder2.4 + cassandra1.2?

zhouhero avatar Mar 11 '13 01:03 zhouhero

by the way, is the getCountResult() ok in kundera2.5?

zhouhero avatar May 09 '13 02:05 zhouhero