In memory POJO based primary and secondary indices
Switch branches/tags
Nothing to show
Latest commit 6294d14 Feb 13, 2012 kalle 0.2.3
removed use of
fixed versions in pom
Failed to load latest commit information.


POJO entity store, intended for use with Prevayler.

POJOs does not have to aware of their own identity.

POJOs are added to the primary index of all super classes and super interfaces,
making it possible to iterate and access all instances of a certain type.

There is abstract support for secondary indices
implemented using a Map<SecondaryKey, Set<Entity>>,
but could be anything from a iterator to a Lucene index if you want to save RAM.

Annotation at field level using UML class diagram semantics is used
to de/couple associations etc when POJOs are updated in the entity store.

The most abstract version of this API looks something like this:

class EntityStore {
  PrimaryIndex<IdentityType, EntityType> getPrimaryIndex(Class<IdentityType> identityType, Class<EntityType> entityType);

class PrimaryIndex<IdentityType, EntityType> implements Iterable<EntityType> {
  SecondaryIndex getSecondaryIndex(String name);
  EntityType put(IdentityType identity, EntityType entity);
  EntityType get(IdentityType identity);
  EntityType remove(IdentityType identity);

class SecondaryIndex<ResultType, IdentityType, EntityType> {
  ResultType get(Object... parameters);
  Set<ResultType> list(Object... parameters);

Caveat emptor:
* Identities must be unique within the application, eg a UUID. (Comes with DeterministicUIDHandler)
* Secondary indices will not be updated unless you re-put the entity in the store or rebuild the secondary index.
* Identities must be set before putting an entity to the store.

There is virtually no documentation but a bit of unit tests:

The test domain model can be viewed as UML class diagram here:

This depends on maven project kodapan-common <> for annotations, reflection and collections. mvn install.