T
- the type of entity which we will be interacting with the DAO withPK
- the id of the entity which we will be interacting with the DAO withpublic class StandardTransactionService<T extends JpaEntity<PK>,PK> extends java.lang.Object implements TransactionService<T,PK>
Transactional
annotations
so as to handle the transaction in a generic way. Do NOT wrap any call to a TransactionService in
a @Transactional
annotation. The passed in DAO
is used for all database calls and defines what type of entity can be retrieved/inserted into
the database.Constructor and Description |
---|
StandardTransactionService(GenericDao<T,PK> genericDao) |
Modifier and Type | Method and Description |
---|---|
void |
add(T entity)
Adds an object of type T.
|
java.util.List<T> |
batchUpdate(java.util.List<T> transientObjects)
Updates all entities passed in and returns a list of the updated objects
|
T |
find(PK id)
Get a T record using it's id
|
java.util.List<T> |
findAll()
Gets a List
|
T |
merge(T transientObject)
Adds or updates an object of type T
|
java.util.List<T> |
query(java.lang.String queryString,
java.util.Map<java.lang.String,java.lang.Object> queryParameters)
Queries the current table using the passed in where clause
|
void |
remove(T persistentObject)
Deletes entity T from table.
|
public StandardTransactionService(GenericDao<T,PK> genericDao)
@Transactional(readOnly=false) public void add(T entity)
@Transactional(readOnly=false) public T merge(T transientObject)
@Transactional(readOnly=true) public T find(PK id) throws javax.persistence.EntityNotFoundException
@Transactional(readOnly=true) public java.util.List<T> findAll()
@Transactional(readOnly=false) public void remove(T persistentObject) throws javax.persistence.EntityNotFoundException
@Transactional(readOnly=true) public java.util.List<T> query(java.lang.String queryString, java.util.Map<java.lang.String,java.lang.Object> queryParameters)
@Transactional(readOnly=false) public java.util.List<T> batchUpdate(java.util.List<T> transientObjects)
batchUpdate
in interface TransactionService<T extends JpaEntity<PK>,PK>
transientObjects
- List