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