org.neodatis.odb.impl.main
Class ODBAdapter

java.lang.Object
  extended by org.neodatis.odb.impl.main.ODBAdapter
All Implemented Interfaces:
ODB
Direct Known Subclasses:
LocalODB, ODBForTrigger, RemoteODBClient, SameVMODBClient

public abstract class ODBAdapter
extends java.lang.Object
implements ODB

A basic adapter for ODB interface

Author:
osmadja

Field Summary
protected  IClassIntrospector classIntrospector
           
protected  IStorageEngine storageEngine
           
 
Constructor Summary
ODBAdapter(IStorageEngine storageEngine)
           
 
Method Summary
 void addDeleteTrigger(java.lang.Class clazz, DeleteTrigger trigger)
          USed to add a delete trigger callback for the specific class
 void addInsertTrigger(java.lang.Class clazz, InsertTrigger trigger)
          Used to add an insert trigger callback for the specific class
 void addSelectTrigger(java.lang.Class clazz, SelectTrigger trigger)
          Used to add a select trigger callback for the specific class
 void addUpdateTrigger(java.lang.Class clazz, UpdateTrigger trigger)
          Used to add an update trigger callback for the specific class
 void close()
          Closes the database.
 void commit()
          Commit all the change of the database @
 void commitAndClose()
           
 java.math.BigInteger count(CriteriaQuery query)
          Returns the number of objects that satisfy the query
 CriteriaQuery criteriaQuery(java.lang.Class clazz)
           
 CriteriaQuery criteriaQuery(java.lang.Class clazz, ICriterion criterion)
           
 void defragmentTo(java.lang.String newFileName)
          Defragment ODB Database
 OID delete(java.lang.Object object)
          Delete an object from database
 OID deleteCascade(java.lang.Object object)
          Delete an object and all its sub objects
 void deleteObjectWithId(OID oid)
          Delete an object from the database with the id
 void disconnect(java.lang.Object object)
          Used to disconnect the object from the current session.
 ODBExt ext()
          Get the extension of ODB to get access to advanced functions
 ClassRepresentation getClassRepresentation(java.lang.Class clazz)
          Get an abstract representation of a class
 ClassRepresentation getClassRepresentation(java.lang.String fullClassName)
          Get an abstract representation of a class
 ClassRepresentation getClassRepresentation(java.lang.String fullClassName, boolean loadClass)
           
 java.lang.String getName()
          Return the name of the database
 java.lang.Object getObjectFromId(OID id)
          Get the object with a specific id *
 OID getObjectId(java.lang.Object object)
          Get the id of an ODB-aware object
<T> Objects<T>
getObjects(java.lang.Class clazz)
          Get all objects of a specific type
<T> Objects<T>
getObjects(java.lang.Class clazz, boolean inMemory)
          Get all objects of a specific type
<T> Objects<T>
getObjects(java.lang.Class clazz, boolean inMemory, int startIndex, int endIndex)
           
<T> Objects<T>
getObjects(IQuery query)
          Search for objects that matches the query.
<T> Objects<T>
getObjects(IQuery query, boolean inMemory)
          Search for objects that matches the native query.
<T> Objects<T>
getObjects(IQuery query, boolean inMemory, int startIndex, int endIndex)
          Return a list of objects that matches the query
 IRefactorManager getRefactorManager()
          Returns the object used to refactor the database
 ISession getSession()
           
 Values getValues(IValuesQuery query)
          Search for objects that matches the query.
 boolean isClosed()
           
 void reconnect(java.lang.Object object)
           
 void rollback()
          Undo all uncommitted changes
 void run()
          or shutdown hook
 OID store(java.lang.Object object)
          Store a plain java Object in the ODB Database
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

storageEngine

protected IStorageEngine storageEngine

classIntrospector

protected IClassIntrospector classIntrospector
Constructor Detail

ODBAdapter

public ODBAdapter(IStorageEngine storageEngine)
Method Detail

commit

public void commit()
Description copied from interface: ODB
Commit all the change of the database @

Specified by:
commit in interface ODB

rollback

public void rollback()
Description copied from interface: ODB
Undo all uncommitted changes

Specified by:
rollback in interface ODB

commitAndClose

public void commitAndClose()

store

public OID store(java.lang.Object object)
Description copied from interface: ODB
Store a plain java Object in the ODB Database

Specified by:
store in interface ODB
Parameters:
object - A plain Java Object

getObjects

public <T> Objects<T> getObjects(java.lang.Class clazz)
Description copied from interface: ODB
Get all objects of a specific type

Specified by:
getObjects in interface ODB
Parameters:
clazz - The type of the objects
Returns:
The list of objects

getObjects

public <T> Objects<T> getObjects(java.lang.Class clazz,
                                 boolean inMemory)
Description copied from interface: ODB
Get all objects of a specific type

Specified by:
getObjects in interface ODB
Parameters:
clazz - The type of the objects
inMemory - if true, preload all objects,if false,load on demand
Returns:
The list of objects

getObjects

public <T> Objects<T> getObjects(java.lang.Class clazz,
                                 boolean inMemory,
                                 int startIndex,
                                 int endIndex)
Specified by:
getObjects in interface ODB
Parameters:
clazz - The type of the objects
inMemory - if true, preload all objects,if false,load on demand
startIndex - The index of the first object
endIndex - The index of the last object that must be returned
Returns:
A List of objects

close

public void close()
Description copied from interface: ODB
Closes the database. Automatically commit uncommitted changes

Specified by:
close in interface ODB

delete

public OID delete(java.lang.Object object)
Description copied from interface: ODB
Delete an object from database

Specified by:
delete in interface ODB

deleteCascade

public OID deleteCascade(java.lang.Object object)
Description copied from interface: ODB
Delete an object and all its sub objects

Specified by:
deleteCascade in interface ODB
Returns:

deleteObjectWithId

public void deleteObjectWithId(OID oid)
Delete an object from the database with the id

Specified by:
deleteObjectWithId in interface ODB
Parameters:
oid - The object id to be deleted @

getObjects

public <T> Objects<T> getObjects(IQuery query)
Description copied from interface: ODB
Search for objects that matches the query.

Specified by:
getObjects in interface ODB
Returns:
The list of objects

getValues

public Values getValues(IValuesQuery query)
Description copied from interface: ODB
Search for objects that matches the query.

Specified by:
getValues in interface ODB
Returns:
The list of values

count

public java.math.BigInteger count(CriteriaQuery query)
Description copied from interface: ODB
Returns the number of objects that satisfy the query

Specified by:
count in interface ODB
Returns:
The number of objects that satisfy the query

getObjects

public <T> Objects<T> getObjects(IQuery query,
                                 boolean inMemory)
Description copied from interface: ODB
Search for objects that matches the native query.

Specified by:
getObjects in interface ODB
Returns:
The list of objects

getObjects

public <T> Objects<T> getObjects(IQuery query,
                                 boolean inMemory,
                                 int startIndex,
                                 int endIndex)
Description copied from interface: ODB
Return a list of objects that matches the query

Specified by:
getObjects in interface ODB
inMemory - if true, preload all objects,if false,load on demand
startIndex - The index of the first object
endIndex - The index of the last object that must be returned
Returns:
A List of objects, if start index and end index are -1, they are ignored. If not, the length of the sublist is endIndex - startIndex

getSession

public ISession getSession()

getObjectId

public OID getObjectId(java.lang.Object object)
Description copied from interface: ODB
Get the id of an ODB-aware object

Specified by:
getObjectId in interface ODB
Returns:
The ODB internal object id

getObjectFromId

public java.lang.Object getObjectFromId(OID id)
Description copied from interface: ODB
Get the object with a specific id *

Specified by:
getObjectFromId in interface ODB
Returns:
The object with the specific id @

defragmentTo

public void defragmentTo(java.lang.String newFileName)
Description copied from interface: ODB
Defragment ODB Database

Specified by:
defragmentTo in interface ODB

getClassRepresentation

public ClassRepresentation getClassRepresentation(java.lang.Class clazz)
Description copied from interface: ODB
Get an abstract representation of a class

Specified by:
getClassRepresentation in interface ODB
Returns:
a public meta-representation of a class

getClassRepresentation

public ClassRepresentation getClassRepresentation(java.lang.String fullClassName)
Description copied from interface: ODB
Get an abstract representation of a class

Specified by:
getClassRepresentation in interface ODB
Returns:
a public meta-representation of a class

getClassRepresentation

public ClassRepresentation getClassRepresentation(java.lang.String fullClassName,
                                                  boolean loadClass)
Specified by:
getClassRepresentation in interface ODB

run

public void run()
or shutdown hook


addUpdateTrigger

public void addUpdateTrigger(java.lang.Class clazz,
                             UpdateTrigger trigger)
Description copied from interface: ODB
Used to add an update trigger callback for the specific class

Specified by:
addUpdateTrigger in interface ODB

addInsertTrigger

public void addInsertTrigger(java.lang.Class clazz,
                             InsertTrigger trigger)
Description copied from interface: ODB
Used to add an insert trigger callback for the specific class

Specified by:
addInsertTrigger in interface ODB

addDeleteTrigger

public void addDeleteTrigger(java.lang.Class clazz,
                             DeleteTrigger trigger)
Description copied from interface: ODB
USed to add a delete trigger callback for the specific class

Specified by:
addDeleteTrigger in interface ODB

addSelectTrigger

public void addSelectTrigger(java.lang.Class clazz,
                             SelectTrigger trigger)
Description copied from interface: ODB
Used to add a select trigger callback for the specific class

Specified by:
addSelectTrigger in interface ODB

getRefactorManager

public IRefactorManager getRefactorManager()
Description copied from interface: ODB
Returns the object used to refactor the database

Specified by:
getRefactorManager in interface ODB

ext

public ODBExt ext()
Description copied from interface: ODB
Get the extension of ODB to get access to advanced functions

Specified by:
ext in interface ODB

disconnect

public void disconnect(java.lang.Object object)
Description copied from interface: ODB
Used to disconnect the object from the current session. The object is removed from the cache

Specified by:
disconnect in interface ODB

reconnect

public void reconnect(java.lang.Object object)
Specified by:
reconnect in interface ODB

isClosed

public boolean isClosed()
Specified by:
isClosed in interface ODB
Returns:

criteriaQuery

public CriteriaQuery criteriaQuery(java.lang.Class clazz,
                                   ICriterion criterion)
Specified by:
criteriaQuery in interface ODB

criteriaQuery

public CriteriaQuery criteriaQuery(java.lang.Class clazz)
Specified by:
criteriaQuery in interface ODB

getName

public java.lang.String getName()
Description copied from interface: ODB
Return the name of the database

Specified by:
getName in interface ODB
Returns:
the file name in local mode and the base id (alias) in client server mode.