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

Closed
zhouhero opened this Issue Dec 14, 2012 · 18 comments

Comments

Projects
None yet
4 participants
@zhouhero

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

"select count(c.id) from Test1Entity "

Can anyone help me!

@mevivs

This comment has been minimized.

Show comment Hide comment
@mevivs

mevivs Dec 14, 2012

Collaborator

Aggregate functions are not supported.

-Vivek

Collaborator

mevivs commented Dec 14, 2012

Aggregate functions are not supported.

-Vivek

@zhouhero

This comment has been minimized.

Show comment Hide comment
@zhouhero

zhouhero Dec 14, 2012

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!!!!!!

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!!!!!!

@impetus-opensource

This comment has been minimized.

Show comment Hide comment
@impetus-opensource

impetus-opensource Dec 14, 2012

Collaborator

I will try to get this working in 2.3 release.

-Vivek

Collaborator

impetus-opensource commented Dec 14, 2012

I will try to get this working in 2.3 release.

-Vivek

@zhouhero

This comment has been minimized.

Show comment Hide comment
@zhouhero

zhouhero Dec 14, 2012

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

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

@mevivs

This comment has been minimized.

Show comment Hide comment
@mevivs

mevivs Jan 22, 2013

Collaborator

Support added on latest trunk, will be released with 2.3

-Vivek

Collaborator

mevivs commented Jan 22, 2013

Support added on latest trunk, will be released with 2.3

-Vivek

@zhouhero

This comment has been minimized.

Show comment Hide comment
@zhouhero

zhouhero Jan 22, 2013

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

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

@zhouhero zhouhero closed this Jan 22, 2013

@zhouhero

This comment has been minimized.

Show comment Hide comment
@zhouhero

zhouhero Jan 29, 2013

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

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

@zhouhero zhouhero reopened this Jan 29, 2013

@zhouhero

This comment has been minimized.

Show comment Hide comment
@zhouhero

zhouhero Jan 29, 2013

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

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

@mevivs

This comment has been minimized.

Show comment Hide comment
@mevivs

mevivs Jan 29, 2013

Collaborator

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

Collaborator

mevivs commented Jan 29, 2013

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

@zhouhero

This comment has been minimized.

Show comment Hide comment
@zhouhero

zhouhero Jan 30, 2013

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()?

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()?

@kkmishra

This comment has been minimized.

Show comment Hide comment
@kkmishra

kkmishra Jan 30, 2013

Contributor

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 notifications@github.com 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

Contributor

kkmishra commented Jan 30, 2013

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 notifications@github.com 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

@zhouhero

This comment has been minimized.

Show comment Hide comment
@zhouhero

zhouhero Jan 31, 2013

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

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

@mevivs

This comment has been minimized.

Show comment Hide comment
@mevivs

mevivs Jan 31, 2013

Collaborator

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

Collaborator

mevivs commented Jan 31, 2013

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

@zhouhero

This comment has been minimized.

Show comment Hide comment
@zhouhero

zhouhero Jan 31, 2013

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.

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.

@mevivs

This comment has been minimized.

Show comment Hide comment
@mevivs

mevivs Jan 31, 2013

Collaborator

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

-Vivek

Collaborator

mevivs commented Jan 31, 2013

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

-Vivek

@zhouhero

This comment has been minimized.

Show comment Hide comment
@zhouhero

zhouhero Feb 1, 2013

As you know , there are many meta infomations' problems in thrift cql api .
Pls refer to: impetus-opensource#170

zhouhero commented Feb 1, 2013

As you know , there are many meta infomations' problems in thrift cql api .
Pls refer to: impetus-opensource#170

@zhouhero

This comment has been minimized.

Show comment Hide comment
@zhouhero

zhouhero Mar 11, 2013

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

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

@zhouhero

This comment has been minimized.

Show comment Hide comment
@zhouhero

zhouhero May 9, 2013

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

zhouhero commented May 9, 2013

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

@mevivs mevivs added this to the 2.11 release milestone Feb 5, 2014

@mevivs mevivs closed this Mar 28, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment