Skip to Main Content

Berkeley DB Family

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get a count of records when using Persistence API?

531207Aug 31 2006 — edited Sep 1 2006
i noticed there is no method i could use to get a count number of db record when using Persistence API.
by now i'm using:

while(myEntityCursor.next()!=null)
count ++;

but i'm sure that would not be a good implementation. Could anyone help me for that?

Thanks
Richie

Comments

Greybird-Oracle
There is currently no record count method in the DPL (Direct Persistence Layer) nor in the base JE API.

You can call EntityIndex.map().size() to get a record count. However, this is implemented by iterating over all records using read uncommitted. So this is no faster than if you iterate yourself (as you've already done) but using read uncommitted (Cursor.READ_UNCOMMITTED or LockMode.READ_UNCOMMITTED).

In the next release we are adding a faster count to the base API and the DPL. This will be used automatically by EntityIndex.map().size(). This count, just like the count obtained by iterating with read uncommitted, will not be transactionally correct.

Mark
531207
got that.

thanks for your reply and now i'm expecting for the next release,

thanks again and good luck.

Richie
1 - 2
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Sep 29 2006
Added on Aug 31 2006
2 comments
1,128 views