|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.akquinet.jbosscc.needle.db.transaction.TransactionHelper
public class TransactionHelper
Utility class to manage transactions conveniently.
| Constructor Summary | |
|---|---|
TransactionHelper(javax.persistence.EntityManager manager)
|
|
| Method Summary | ||
|---|---|---|
|
executeInTransaction(Runnable<T> runnable)
see executeInTransaction(runnable, clearAfterCommit) . |
|
|
executeInTransaction(Runnable<T> runnable,
boolean clearAfterCommit)
Encapsulates execution of runnable.run() in transactions. |
|
javax.persistence.EntityManager |
getEntityManager()
|
|
|
loadAllObjects(Class<T> clazz)
Returns all objects of the given class in persistence context. |
|
|
loadObject(Class<T> clazz,
Object id)
Finds and returns object of the given id in the persistence context. |
|
|
loadObject(javax.persistence.EntityManager entityManager,
Class<T> clazz,
Object id)
|
|
|
persist(T obj)
|
|
|
persist(T obj,
javax.persistence.EntityManager entityManager)
|
|
|
saveObject(T obj)
Saves the given object in the database. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TransactionHelper(javax.persistence.EntityManager manager)
| Method Detail |
|---|
public final <T> T saveObject(T obj)
throws Exception
T - -- type of given object objobj - -- object to save
Exception - -- save objects failed
public final <T> T loadObject(Class<T> clazz,
Object id)
throws Exception
T - -- type of searched objectclazz - -- type of searched objectid - -- technical id of searched object
Exception - -- finding object failed
public final <T> List<T> loadAllObjects(Class<T> clazz)
throws Exception
T - -- type of searched objectsclazz - -- type of searched objects
Exception - -- finding objects failed
public final <T> T executeInTransaction(Runnable<T> runnable,
boolean clearAfterCommit)
throws Exception
T - -- result type of runnable.run()runnable - -- algorithm to executeclearAfterCommit - -- true triggers entityManager.clear() after
transaction commit
Exception - -- execution failed
public final <T> T executeInTransaction(Runnable<T> runnable)
throws Exception
T - -- result type of runnable.run()runnable - -- algorithm to execute
Exception - -- execution failedpublic final javax.persistence.EntityManager getEntityManager()
public <T> T persist(T obj,
javax.persistence.EntityManager entityManager)
public <T> T persist(T obj)
public <T> T loadObject(javax.persistence.EntityManager entityManager,
Class<T> clazz,
Object id)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||