com.ikokoon.serenity.persistence
Interface IDataBase

All Known Implementing Classes:
DataBase, DataBaseJpa, DataBaseOdb, DataBaseRam

public interface IDataBase

This is the persistence interface for the Serenity code coverage and dependency functionality.

Since:
12.08.09
Version:
01.00 -------------------------------------------------------------
, 01.1
Removed the JPA oriented methods in favour of in memory as JPA was hopelessly too slow. -------------------------------------------------------------
, 01.2
Added the listeners to the databases so the manager can release them from the map. Changed the IDataBase interface to be generic so Neodatis can be integrated easier and modified several methods to include the class that is being selected as most persistence libraries will need this for their selection., 01.3
Added a find method that can be implemented as a fuzzy search method by the implementation with multiple search criteria. For example 'where x like n and y in m'.
Author:
Michael Couck

Nested Class Summary
static class IDataBase.DataBaseManager
          This class manages the databases if there are more than one.
 
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.
 

Method Detail

persist

<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

<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

<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

<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

find

<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

<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

<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

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

Returns:
whether the database is open or closed

close

void close()
Closes the database.



Copyright © 2010. All Rights Reserved.