T
- the generic typepublic abstract class AbstractPersistence<T> extends Object implements DaoUpdater<T>, DaoViewer<T>, JavaPersistenceHandler<T>
Modifier and Type | Class and Description |
---|---|
static class |
AbstractPersistence.SQL_ORDER
The Enum SQL_ORDER.
|
Modifier and Type | Field and Description |
---|---|
String |
AND
The and.
|
protected javax.persistence.EntityManagerFactory |
entityManagerFactory
The entity manager factory.
|
protected org.slf4j.Logger |
logger
The logger.
|
protected String |
tableName
The table name.
|
Constructor and Description |
---|
AbstractPersistence(javax.persistence.EntityManagerFactory factory,
String tableName)
Instantiates a new abstract persistence.
|
Modifier and Type | Method and Description |
---|---|
int |
countItems()
Count items.
|
boolean |
create(T item)
Creates the.
|
javax.persistence.EntityManager |
createNewManager()
Creates the new manager.
|
int |
deleteItemByInternalId(long internalId)
Delete item by internal id.
|
List<T> |
executeCriteriaQuery(javax.persistence.criteria.CriteriaQuery<Object> criteriaQuery)
Execute criteria query.
|
List<T> |
executeTypedQuery(javax.persistence.criteria.CriteriaQuery<Object> cq,
int startIndex,
int offset)
Execute typed query.
|
javax.persistence.criteria.CriteriaBuilder |
getCriteriaBuilder()
Gets the criteria builder.
|
javax.persistence.EntityManagerFactory |
getEntityManagerFactory()
Gets the entity manager factory.
|
T |
getItemByKey(Long id,
Class<T> t)
Gets the item by key.
|
List<T> |
getItemForInternalID(long internalID)
Gets the item for internal ID.
|
List<T> |
getRows()
Gets the rows.
|
List<T> |
getRows(int startIndex,
int offset)
Gets the rows.
|
List<T> |
getRowsFiltered(Map<String,String> andFilterMap)
Gets the rows filtered.
|
List<T> |
getRowsOrdered(String orderByField,
AbstractPersistence.SQL_ORDER order)
Gets the rows ordered.
|
boolean |
insert(T item)
Insert.
|
boolean |
remove(T item,
boolean transaction)
Removes the.
|
int |
removeAll()
Removes the all.
|
abstract javax.persistence.criteria.Root<T> |
rootFrom(javax.persistence.criteria.CriteriaQuery<Object> cq)
Root from.
|
T |
update(T item)
Update.
|
protected javax.persistence.EntityManagerFactory entityManagerFactory
public final String AND
protected org.slf4j.Logger logger
protected String tableName
public AbstractPersistence(javax.persistence.EntityManagerFactory factory, String tableName)
factory
- the factorytableName
- the table namepublic abstract javax.persistence.criteria.Root<T> rootFrom(javax.persistence.criteria.CriteriaQuery<Object> cq)
JavaPersistenceHandler
rootFrom
in interface JavaPersistenceHandler<T>
cq
- the cqpublic boolean create(T item) throws DatabaseServiceException
DaoUpdater
create
in interface DaoUpdater<T>
item
- the itemDatabaseServiceException
- the database service exceptionpublic boolean insert(T item) throws DatabaseServiceException
DaoUpdater
insert
in interface DaoUpdater<T>
item
- the itemDatabaseServiceException
- the database service exceptionpublic T update(T item) throws DatabaseServiceException
DaoUpdater
update
in interface DaoUpdater<T>
item
- the itemDatabaseServiceException
- the database service exceptionpublic boolean remove(T item, boolean transaction) throws DatabaseServiceException
DaoUpdater
remove
in interface DaoUpdater<T>
item
- the itemtransaction
- the transactionDatabaseServiceException
- the database service exceptionpublic List<T> getRows() throws DatabaseServiceException
DaoViewer
getRows
in interface DaoViewer<T>
DatabaseServiceException
- the database service exceptionpublic List<T> getRowsOrdered(String orderByField, AbstractPersistence.SQL_ORDER order) throws DatabaseServiceException
DaoViewer
getRowsOrdered
in interface DaoViewer<T>
orderByField
- the order by fieldorder
- the orderDatabaseServiceException
- the database service exceptionpublic List<T> getRows(int startIndex, int offset) throws DatabaseServiceException
DaoViewer
getRows
in interface DaoViewer<T>
startIndex
- the start indexoffset
- the offsetDatabaseServiceException
- the database service exceptionpublic int countItems() throws DatabaseServiceException
DaoViewer
countItems
in interface DaoViewer<T>
DatabaseServiceException
- the database service exceptionpublic List<T> getRowsFiltered(Map<String,String> andFilterMap) throws DatabaseServiceException
DaoViewer
getRowsFiltered
in interface DaoViewer<T>
andFilterMap
- the filter mapDatabaseServiceException
- the database service exceptionpublic int removeAll() throws DatabaseServiceException
DaoUpdater
removeAll
in interface DaoUpdater<T>
DatabaseServiceException
- the database service exceptionpublic T getItemByKey(Long id, Class<T> t) throws DatabaseServiceException
DaoViewer
getItemByKey
in interface DaoViewer<T>
id
- the idt
- the tDatabaseServiceException
- the database service exceptionpublic javax.persistence.criteria.CriteriaBuilder getCriteriaBuilder() throws DatabaseServiceException
JavaPersistenceHandler
getCriteriaBuilder
in interface JavaPersistenceHandler<T>
DatabaseServiceException
- the database service exceptionpublic javax.persistence.EntityManagerFactory getEntityManagerFactory()
JavaPersistenceHandler
getEntityManagerFactory
in interface JavaPersistenceHandler<T>
public javax.persistence.EntityManager createNewManager() throws DatabaseServiceException
JavaPersistenceHandler
createNewManager
in interface JavaPersistenceHandler<T>
DatabaseServiceException
- the database service exceptionpublic List<T> executeCriteriaQuery(javax.persistence.criteria.CriteriaQuery<Object> criteriaQuery) throws DatabaseServiceException
JavaPersistenceHandler
executeCriteriaQuery
in interface JavaPersistenceHandler<T>
criteriaQuery
- the criteria queryDatabaseServiceException
- the database service exceptionpublic List<T> executeTypedQuery(javax.persistence.criteria.CriteriaQuery<Object> cq, int startIndex, int offset) throws DatabaseServiceException
JavaPersistenceHandler
executeTypedQuery
in interface JavaPersistenceHandler<T>
cq
- the cqstartIndex
- the start indexoffset
- the offsetDatabaseServiceException
- the database service exceptionpublic int deleteItemByInternalId(long internalId) throws DatabaseServiceException
DaoUpdater
deleteItemByInternalId
in interface DaoUpdater<T>
internalId
- the internal idDatabaseServiceException
- the database service exceptionpublic List<T> getItemForInternalID(long internalID) throws DatabaseServiceException
internalID
- the internal IDDatabaseServiceException
- the database service exceptionCopyright © 2019. All Rights Reserved.