com.ikokoon.serenity.persistence
Class DataBaseOdb

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

public class DataBaseOdb
extends DataBase

This is the database class using Neodatis as the persistence tool.

Since:
01.12.09
Version:
01.00
Author:
Michael Couck

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.ikokoon.serenity.persistence.IDataBase
IDataBase.DataBaseManager
 
Constructor Summary
DataBaseOdb(java.lang.String dataBaseFile)
          Constructor initialises a DataBaseOdb object.
 
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
 

Constructor Detail

DataBaseOdb

public DataBaseOdb(java.lang.String dataBaseFile)
Constructor initialises a DataBaseOdb object.

Parameters:
dataBaseFile - the file to open the database with
create - whether to create a new database essentially deleting the database file and creating a new one or to use the data in the existing database file
Method Detail

find

public <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 <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 <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

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)
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

persist

public <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

remove

public <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 boolean isClosed()
Checks the open status of the database.

Returns:
whether the database is open or closed

close

public void close()
Closes the database.



Copyright © 2010. All Rights Reserved.