| 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface JpaHelper
Utility class and methods to make database access easier. Type safety is given under the following conditions: When searching, the class provided must be a domain class and any properties provided must be applicable to that class. For example, selectFrom(A.class).with("b", some_b) requires that A is a domain class with a property b of a type corresponding to the class of some_b.
| Method Summary | ||
|---|---|---|
 void | 
clear()
Clear the session.  | 
|
 | 
contains(T instance)
Contains an entry.  | 
|
 | 
detach(T instance)
Remove the given entity from the persistence context, causing a managed entity to become detached.  | 
|
 void | 
doInTransaction(Runnable r)
 | 
|
 | 
findByKey(Class<T> clazz,
          Integer key)
Finds an entity by its primary key.  | 
|
 void | 
flush()
Flush the session.  | 
|
 | 
merge(T instance)
Merge the state of the given entity into the current persistence context.  | 
|
 | 
persist(T instance)
Makes an entity managed and persistent.  | 
|
 | 
refresh(T instance)
Refresh the state of the instance from the database, overwriting changes made to the entity, if any.  | 
|
 | 
remove(T instance)
Delete a MANAGED entity. | 
|
 | 
selectFrom(Class<T> cls)
Initiate a select query.  | 
|
| Method Detail | 
|---|
<T> JpaQuery<T> selectFrom(Class<T> cls)
T - Generic type parameter for the class to select from.cls - The class to select from.
<T> Boolean contains(T instance)
T - The type parameter.instance - The object to check if the entity manager contains it.
<T> T merge(T instance)
DETACHED to MANAGED.
T - The type parameter, to allow us to return the merged object.instance - The object to merge.
<T> void detach(T instance)
MANAGED to DETACHED.
T - The type parameter.instance - The object to detach.<T> void persist(T instance)
NEW/REMOVED 
 to MANAGED. 
 On the next flush or commit it is inserted into the database.
T - The type parameter.instance - The object to persist.<T> void remove(T instance)
MANAGED entity. Transition from state MANAGED to REMOVED.
 On the next flush or commit it is removed from the database.
T - The type parameter.instance - The instance to delete.<T> void refresh(T instance)
MANAGED to MANAGED again.
T - The type parameter.instance - The instance to refresh.
<T> T findByKey(Class<T> clazz,
                Integer key)
MANAGED.
T - The type parameter, to allow us to return the searched object.clazz - The entity class.key - The primary key.
MANAGED).void clear()
void flush()
void doInTransaction(Runnable r)
  | 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||