Skip to content

kodapan/kodapan-entity-store

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

http://github.com/karlwettin/kodapan-entity-store/blob/master/src/test/java/se/kodapan/index/TestEntityStore.java

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

http://github.com/karlwettin/kodapan-entity-store/raw/master/src/test/java/se/kodapan/index/domain/doc-files/classdiagram.pdf




This depends on maven project kodapan-common <http://github.com/karlwettin/kodapan-common> for annotations, reflection and collections. mvn install.


karl.wettin@gmail.com

About

In memory POJO based primary and secondary indices

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages