org.olat.core.commons.persistence
Interface DB

All Known Subinterfaces:
DBJunit
All Known Implementing Classes:
DBImpl, DBJunitImpl

public interface DB


Method Summary
 void addTransactionListener(ITransactionListener listener)
          Add an ITransactionListener to this DB instance.
 void closeSession()
          Close the database session.
 void commit()
          Call this to commit current changes.
 void commitAndCloseSession()
          Checks if the transaction needs to be committed and does so if this is the case, plus closes the connection in any case guaranteed.
 DBQuery createQuery(java.lang.String query)
          Create a DBQuery
 int delete(java.lang.String query, java.lang.Object[] values, org.hibernate.type.Type[] types)
          Deletion query.
 int delete(java.lang.String query, java.lang.Object value, org.hibernate.type.Type type)
          Deletion query.
 void deleteObject(java.lang.Object object)
          Delete an object.
 java.util.List find(java.lang.String query)
          Find objects based on query
 java.util.List find(java.lang.String query, java.lang.Object[] values, org.hibernate.type.Type[] types)
          Find objects based on query
 java.util.List find(java.lang.String query, java.lang.Object value, org.hibernate.type.Type type)
          Find objects based on query
 java.lang.Object findObject(java.lang.Class theClass, java.lang.Long key)
          Find an object.
 void forceSetDebugLogLevel(boolean enabled)
          temp debug only
 org.hibernate.stat.Statistics getStatistics()
          Statistics must be enabled first, when you want to use it.
 void intermediateCommit()
          Call this to intermediate commit current changes.
 boolean isError()
           
 java.lang.Object loadObject(java.lang.Class theClass, java.lang.Long key)
          Load an object.
 Persistable loadObject(Persistable persistable)
          see DB.loadObject(Persistable persistable, boolean forceReloadFromDB)
 Persistable loadObject(Persistable persistable, boolean forceReloadFromDB)
          loads an object if needed.
 void removeTransactionListener(ITransactionListener listener)
          Removes an ITransactionListener from this DB instance.
 void rollback()
          Call this to rollback current changes.
 void rollbackAndCloseSession()
          Calls rollback and closes the connection guaranteed.
 void saveObject(java.lang.Object object)
          Save an object.
 void updateObject(java.lang.Object object)
          Update an object.
 

Method Detail

forceSetDebugLogLevel

void forceSetDebugLogLevel(boolean enabled)
temp debug only


addTransactionListener

void addTransactionListener(ITransactionListener listener)
Add an ITransactionListener to this DB instance.

The ITransactionListener will be informed about commit and rollbacks.

Adding the same listener twice has no effect.

Parameters:
listener - the listener to be added

removeTransactionListener

void removeTransactionListener(ITransactionListener listener)
Removes an ITransactionListener from this DB instance.

If the ITransactionListener is currently not registered, this call has no effect.

Parameters:
listener -

closeSession

void closeSession()
Close the database session.


createQuery

DBQuery createQuery(java.lang.String query)
Create a DBQuery

Parameters:
query -
Returns:
DBQuery

deleteObject

void deleteObject(java.lang.Object object)
Delete an object.

Parameters:
object -

find

java.util.List find(java.lang.String query,
                    java.lang.Object value,
                    org.hibernate.type.Type type)
Find objects based on query

Parameters:
query -
value -
type -
Returns:
List of results.

find

java.util.List find(java.lang.String query,
                    java.lang.Object[] values,
                    org.hibernate.type.Type[] types)
Find objects based on query

Parameters:
query -
values -
types -
Returns:
List of results.

findObject

java.lang.Object findObject(java.lang.Class theClass,
                            java.lang.Long key)
Find an object.

Parameters:
theClass -
key -
Returns:
Object, if any found. or null otherwise

find

java.util.List find(java.lang.String query)
Find objects based on query

Parameters:
query -
Returns:
List of results.

loadObject

java.lang.Object loadObject(java.lang.Class theClass,
                            java.lang.Long key)
Load an object.

Parameters:
theClass -
key -
Returns:
Object.

saveObject

void saveObject(java.lang.Object object)
Save an object.

Parameters:
object -

updateObject

void updateObject(java.lang.Object object)
Update an object.

Parameters:
object -

delete

int delete(java.lang.String query,
           java.lang.Object value,
           org.hibernate.type.Type type)
Deletion query.

Parameters:
query -
value -
type -
Returns:
nr of values deleted

delete

int delete(java.lang.String query,
           java.lang.Object[] values,
           org.hibernate.type.Type[] types)
Deletion query.

Parameters:
query -
values -
types -
Returns:
nr of deleted rows

loadObject

Persistable loadObject(Persistable persistable)
see DB.loadObject(Persistable persistable, boolean forceReloadFromDB)

Parameters:
persistable -
Returns:
the loaded object, never null

loadObject

Persistable loadObject(Persistable persistable,
                       boolean forceReloadFromDB)
loads an object if needed. this makes sense if you have an object which had been generated in a previous hibernate session AND you need to access a Set or a attribute which was defined as a proxy.

Parameters:
persistable - the object which needs to be reloaded
forceReloadFromDB - if true, force a reload from the db (e.g. to catch up to an object commited by another thread which is still in this thread's session cache
Returns:
the loaded Object, never null

commitAndCloseSession

void commitAndCloseSession()
Checks if the transaction needs to be committed and does so if this is the case, plus closes the connection in any case guaranteed.

Use this rather than commit() directly wherever possible!


commit

void commit()
Call this to commit current changes.


rollbackAndCloseSession

void rollbackAndCloseSession()
Calls rollback and closes the connection guaranteed.

Note that this method checks whether the connection and the transaction are open and if they're not, then this method doesn't do anything.


rollback

void rollback()
Call this to rollback current changes.


getStatistics

org.hibernate.stat.Statistics getStatistics()
Statistics must be enabled first, when you want to use it.

Returns:
Return Hibernates statistics object.

intermediateCommit

void intermediateCommit()
Call this to intermediate commit current changes. Use this method in startup process and bulk changes.


isError

boolean isError()
Returns:
True if any errors occured in the previous DB call.