Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Berkely DB > DPL and searchi...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 1749 of 1800
Post > Topic >>

DPL and searching for entities.

by Fabio M <fabio.mancinelli@[EMAIL PROTECTED] > May 22, 2007 at 12:17 PM

Dear all,

I am experimenting with the BDB-JE DPL but I cannot understand how to
search for entities.
I will detail my problem with an example.

I have an Entity with a composite class as its primary key and *no*
secondary keys.
Basically something like that:

@[EMAIL PROTECTED]
 class MyEntity {
  @[EMAIL PROTECTED]
  private ID id;
  ...
}

@[EMAIL PROTECTED]
 class ID {
  @[EMAIL PROTECTED]
(1) private String f1;
  @[EMAIL PROTECTED]
(2) private String f2;
  @[EMAIL PROTECTED]
(3) private String f3;
  ...
}

I can browse all the entities stored in the DB by using

PrimaryIndex<ID, MyEntity> entitiesByID =
store.getPrimaryIndex(ID.class, MyEntity.class);
EntityCursor<Entity> cursor = entitiesByID.entities();
for(MyEntity e : cursor) { ...}

However I would like to do more specific queries, such as 'I want all
the entities for which f1="foo"'.
But I cannot figure out how to express this using the DPL API.

I can think of 2 workarounds:
1) Scanning all the entities looking for the good ones (ugly and slow)
2) Duplicate the f1 field in the MyEntity class and use it as a
SecondaryKey

Maybe the 2nd solution could be reasonable, but I wonder if there is a
"3rd way" that implies the usage of the already existing primary key
without modifying the classes I wrote at the beginning of the message

Thank you for your help.

Cheers,
Fabio




 1 Posts in Topic:
DPL and searching for entities.
Fabio M <fabio.mancine  2007-05-22 12:17:28 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan13V112 Fri Jul 4 18:36:41 CDT 2008.