com.ikokoon.serenity.persistence
Class DataBaseRam

java.lang.Object
  extended by com.ikokoon.serenity.persistence.DataBase
      extended by com.ikokoon.serenity.persistence.DataBaseRam
All Implemented Interfaces:
IDataBase

public final class DataBaseRam
extends DataBase

This is the in memory database. Several options were explored including DB4O, Neodatis, JPA, SQL, and finally none were performant enough. As well as that several hybrids were investigated like including a l1 cache and a l2 cache, but the actual persistence in the case of JPA and SQL was just too slow. This class does everything in memory and commits the data finally to the under lying database once the processing is finished.

Since:
11.10.09
Version:
01.00
Author:
Michael Couck

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.ikokoon.serenity.persistence.IDataBase
IDataBase.DataBaseManager
 
Method Summary
 void close()
          Closes the database.
<E extends Composite<?,?>>
java.util.List<E>
find(java.lang.Class<E> klass)
          Selects all the classes of a particular type.
<E extends Composite<?,?>>
java.util.List<E>
find(java.lang.Class<E> klass, int start, int end)
          Selects all the classes of a particular type starting from an index and going to an index.
<E extends Composite<?,?>>
E
find(java.lang.Class<E> klass, java.util.List<java.lang.Object> parameters)
          Selects a class based on the combination of field values in the parameter list.
<E extends Composite<?,?>>
E
find(java.lang.Class<E> klass, java.lang.Long id)
          Selects a composite based on the class type and the id of the class.
<E extends Composite<?,?>>
java.util.List<E>
find(java.lang.Class<E> klass, java.util.Map<java.lang.String,java.lang.Object> parameters)
          Selects a list of objects based on the values in the objects and the class of the object.
 boolean isClosed()
          Checks the open status of the database.
<E extends Composite<?,?>>
E
persist(E composite)
          Persists an object to a persistent store.
<E extends Composite<?,?>>
E
remove(java.lang.Class<E> klass, java.lang.Long id)
          Removes an object from the database and returns the removed object as a convenience.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

persist

public final <E extends Composite<?,?>> E persist(E composite)
Persists an object to a persistent store.

Parameters:
composite - the composite to persist
Returns:
the composite that is persisted, typically the id will be set by the underlying implementation

find

public final <E extends Composite<?,?>> E find(java.lang.Class<E> klass,
                                               java.lang.Long id)
Selects a composite based on the class type and the id of the class.

Type Parameters:
E - the return type of the class
Parameters:
klass - the type of class to select
id - the unique id of the class
Returns:
the composite with the specified id

find

public final <E extends Composite<?,?>> E find(java.lang.Class<E> klass,
                                               java.util.List<java.lang.Object> parameters)
Selects a class based on the combination of field values in the parameter list.

Type Parameters:
E - the return type of the class
Parameters:
klass - the type of class to select
parameters - the unique combination of field values to select the class with
Returns:
the composite with the specified unique field combination

find

public final <E extends Composite<?,?>> java.util.List<E> find(java.lang.Class<E> klass)
Selects all the classes of a particular type. Note this could potentially return the whole database.

Type Parameters:
E - the return type of the class
Parameters:
klass - the type of class to select
Returns:
a list of all the objects in the database that have the specified class type

find

public <E extends Composite<?,?>> java.util.List<E> find(java.lang.Class<E> klass,
                                                         int start,
                                                         int end)
Selects all the classes of a particular type starting from an index and going to an index.

Type Parameters:
E - the return type of the class
Parameters:
klass - the type of class to select
start - the beginning index to retrieve objects from
end - the end index for the list of objects
Returns:
a list of all the objects in the database that have the specified class type

remove

public final <E extends Composite<?,?>> E remove(java.lang.Class<E> klass,
                                                 java.lang.Long id)
Removes an object from the database and returns the removed object as a convenience.

Type Parameters:
E - the return type of the class
Parameters:
klass - the type of class to select
id - the unique id of the class
Returns:
the composite with the specified id

isClosed

public final boolean isClosed()
Checks the open status of the database.

Returns:
whether the database is open or closed

close

public final void close()
Closes the database.


find

public <E extends Composite<?,?>> java.util.List<E> find(java.lang.Class<E> klass,
                                                         java.util.Map<java.lang.String,java.lang.Object> parameters)
Description copied from interface: IDataBase
Selects a list of objects based on the values in the objects and the class of the object. The implementations can implement multiple search criteria including fuzzy selection etc.

Type Parameters:
E - the return type of the class
Parameters:
klass - the type of class to select
parameters - the parameters to do the selection with. These are the fields in the objects and the values
Returns:
the list of composites that match the selection criteria


Copyright © 2010. All Rights Reserved.