kundera icon indicating copy to clipboard operation
kundera copied to clipboard

Can i use "LIMIT" keyword in JPQL when using cassandra

Open zhouhero opened this issue 13 years ago • 10 comments

Can i use "LIMIT" keyword in JPQL when using cassandra ? as you know CQL can use it now.

zhouhero avatar Jan 22 '13 05:01 zhouhero

LIMIT keyword is not supported as of now, but there are two ways we can achieve this:

  1. Using query.setMaxResults(n);
  2. Running your CQL (native query) directly by:

Query q = entityManager.createNativeQuery("My CQL Query String", MyEntity.class); List entities = q.getResultList();

Regards, Amresh

On Tue, Jan 22, 2013 at 11:12 AM, zhouhero [email protected] wrote:

Can i use "LIMIT" keyword in JPQL when using cassandra ? as you know CQL can use it now.

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

xamry avatar Jan 22 '13 05:01 xamry

by the way, when not do setMaxResults, by default , how many records are return? ※cassandra can return 10,000 records by default.

zhouhero avatar Jan 22 '13 05:01 zhouhero

Default is 100 if you not set it. This is consistent with thrift behavior and Cassandra-cli.

CQL command line returns 10000 results.

Amresh

On Tue, Jan 22, 2013 at 11:21 AM, zhouhero [email protected] wrote:

by the way, when not do setMaxResults, by default , how many records are return? ※cassandra can return 10,000 records by default.

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

xamry avatar Jan 22 '13 06:01 xamry

thank you very much! let me try it.

zhouhero avatar Jan 22 '13 06:01 zhouhero

by the way, Are setFirstResult, setMaxResults implemented? how can i do paging by using kundera?

zhouhero avatar Jan 22 '13 06:01 zhouhero

my db is cassandra.

zhouhero avatar Jan 22 '13 06:01 zhouhero

Pagination support is not yet supported. Cassandra does not offer a way to build cursor like support on db side. Loading everything in-memory and providing implementing custom iterator is possible and we are working on it. But it is going to have extensive memory usage. Also range queries are possible only over OrderedPartitioner(not recommented by casandra), We are planning to build this in future releases.

setFirstResult will make sense once pagination is in place. Alternative way is to fetch first record from returned list of matching results.

-Vivek

mevivs avatar Jan 22 '13 06:01 mevivs

i see, thank you very much! by the way , when kundera 2.3 release? i have heard that it will be released in this weekend by planning.

zhouhero avatar Jan 22 '13 06:01 zhouhero

Releasing on 24th.

-Vivek

mevivs avatar Jan 22 '13 06:01 mevivs

it's perfect!!! Thanks!

zhouhero avatar Jan 22 '13 06:01 zhouhero