|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.olat.core.logging.LogDelegator
org.olat.core.commons.persistence.DBImpl
public class DBImpl
A DB is a central place to get a Hibernate Session. It acts as a facade to the database, transactions and Queries. The hibernateSession is lazy loaded per thread.
| 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 a transaction opened by beginTransaction(). |
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 |
java.lang.Exception |
getError()
Get any errors from a previous DB call. |
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. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public void closeSession()
closeSession in interface DBpublic DBQuery createQuery(java.lang.String query)
createQuery in interface DBquery -
public void deleteObject(java.lang.Object object)
deleteObject in interface DBobject -
public int delete(java.lang.String query,
java.lang.Object value,
org.hibernate.type.Type type)
delete in interface DBquery - value - type -
public int delete(java.lang.String query,
java.lang.Object[] values,
org.hibernate.type.Type[] types)
delete in interface DBquery - values - types -
public java.util.List find(java.lang.String query,
java.lang.Object value,
org.hibernate.type.Type type)
find in interface DBquery - value - type -
public java.util.List find(java.lang.String query,
java.lang.Object[] values,
org.hibernate.type.Type[] types)
find in interface DBquery - values - types -
public java.util.List find(java.lang.String query)
find in interface DBquery -
public java.lang.Object findObject(java.lang.Class theClass,
java.lang.Long key)
findObject in interface DBtheClass - key -
public java.lang.Object loadObject(java.lang.Class theClass,
java.lang.Long key)
loadObject in interface DBtheClass - key -
public void saveObject(java.lang.Object object)
saveObject in interface DBobject - public void updateObject(java.lang.Object object)
updateObject in interface DBobject - public java.lang.Exception getError()
public boolean isError()
isError in interface DBpublic Persistable loadObject(Persistable persistable)
loadObject in interface DBpersistable -
public Persistable loadObject(Persistable persistable,
boolean forceReloadFromDB)
loadObject in interface DBpersistable - the object which needs to be reloadedforceReloadFromDB - 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
public void commitAndCloseSession()
DBUse this rather than commit() directly wherever possible!
commitAndCloseSession in interface DBpublic void rollbackAndCloseSession()
DBNote that this method checks whether the connection and the transaction are open and if they're not, then this method doesn't do anything.
rollbackAndCloseSession in interface DBpublic void commit()
commit in interface DBpublic void rollback()
rollback in interface DBpublic org.hibernate.stat.Statistics getStatistics()
getStatistics in interface DBpublic void intermediateCommit()
DB
intermediateCommit in interface DBDB.intermediateCommit()public void addTransactionListener(ITransactionListener listener)
DBThe ITransactionListener will be informed about commit and rollbacks.
Adding the same listener twice has no effect.
addTransactionListener in interface DBlistener - the listener to be addedpublic void removeTransactionListener(ITransactionListener listener)
DBIf the ITransactionListener is currently not registered, this call has no effect.
removeTransactionListener in interface DBpublic void forceSetDebugLogLevel(boolean enabled)
forceSetDebugLogLevel in interface DB
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||