Package io.tesler.model.core.dao.impl
Class JpaDaoImpl
- java.lang.Object
-
- io.tesler.model.core.dao.impl.JpaDaoImpl
-
- All Implemented Interfaces:
JpaDao
- Direct Known Subclasses:
BaseDAOImpl
@Repository @Primary @Transactional public class JpaDaoImpl extends Object implements JpaDao
-
-
Field Summary
Fields Modifier and Type Field Description protected TransactionService
txService
-
Constructor Summary
Constructors Constructor Description JpaDaoImpl(Set<javax.persistence.EntityManager> entityManagers, TransactionService txService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> void
applyGraph(Class<T> clazz, javax.persistence.criteria.Root<T> root, String fetchGraph)
<T> void
applyGraph(javax.persistence.criteria.Root<T> root, javax.persistence.EntityGraph<? super T> fetchGraph)
protected <T> javax.persistence.TypedQuery<T>
applyPaging(javax.persistence.TypedQuery<T> query, PageSpecification page)
protected <T> Stream<T>
asStream(javax.persistence.TypedQuery<T> query)
void
clear()
void
delete(AbstractEntity o)
<T extends BaseEntity>
Tdelete(Class<T> clazz, Long id)
<T> int
delete(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> spec)
void
deleteWithCompositeKey(EmbeddedKeyable o)
<T extends BaseEntity>
Tevict(T o)
<T> boolean
exists(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> specification)
<T extends BaseEntity>
TfetchBySpecification(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> specification)
<T extends BaseEntity>
TfindById(Class<T> clazz, Long id)
<T extends BaseEntity>
TfindById(String type, Long id)
void
flush()
Long
getCount(Class<?> clazz)
<T> Long
getCount(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> specification)
<T> javax.persistence.EntityGraph<? super T>
getEntityGraph(Class<T> clazz, String name)
<T> javax.persistence.metamodel.EntityType<T>
getEntityType(Class<T> cls)
protected javax.persistence.metamodel.EntityType<BaseEntity>
getEntityType(String name)
<R,T>
TgetFirstResultOrNull(Class<R> rootClass, Class<T> targetClass, Selector<R,T> selector, org.springframework.data.jpa.domain.Specification<R> specification)
<T> T
getFirstResultOrNull(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> specification)
<T> List<Long>
getIds(Class<T> entityClazz, org.springframework.data.jpa.domain.Specification<T> searchSpec)
protected javax.persistence.criteria.JoinType
getJoinType(javax.persistence.criteria.FetchParent fetch, String attrName)
protected javax.persistence.criteria.JoinType
getJoinType(javax.persistence.criteria.From from, String attrName)
<R,T>
List<T>getList(Class<R> rootClass, Class<T> targetClass, Selector<R,T> selector, org.springframework.data.jpa.domain.Specification<R> specification)
<T> List<T>
getList(Class<T> entityClass)
<T,X>
List<T>getList(Class<T> clazz, javax.persistence.metamodel.SingularAttribute<T,X> name, X value)
<T> List<T>
getList(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> specification)
<T> List<T>
getListByIds(Class<T> clazz, List<Long> ids)
<R,T>
ResultPage<T>getPage(Class<R> rootClass, Class<T> targetClass, Selector<R,T> selector, org.springframework.data.jpa.domain.Specification<R> specification, PageSpecification page)
<T> ResultPage<T>
getPage(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> specification, PageSpecification page)
<R,T>
TgetSingleResult(Class<R> rootClass, Class<T> targetClass, Selector<R,T> selector, org.springframework.data.jpa.domain.Specification<R> specification)
<T> T
getSingleResult(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> specification)
<R,T>
TgetSingleResultOrNull(Class<R> rootClass, Class<T> targetClass, Selector<R,T> selector, org.springframework.data.jpa.domain.Specification<R> specification)
<T> T
getSingleResultOrNull(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> specification)
<R,T>
Stream<T>getStream(Class<R> rootClass, Class<T> targetClass, Selector<R,T> selector, org.springframework.data.jpa.domain.Specification<R> specification)
<T> Stream<T>
getStream(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> specification)
protected javax.persistence.EntityManager
getSupportedEntityManager(String entityClazz)
protected <R,T>
javax.persistence.TypedQuery<T>getTypedQuery(Class<R> rootClass, Class<T> targetClass, Selector<R,T> selector, org.springframework.data.jpa.domain.Specification<R> specification)
void
lock(AbstractEntity entity, javax.persistence.LockModeType lockMode, int timeout)
void
lockAndRefresh(AbstractEntity entity, int timeout)
void
refresh(AbstractEntity o)
void
revert(AbstractEntity entity)
<T> T
save(Object entity)
<T> List<T>
saveAll(List<T> entities)
void
saveWithCompositeKey(EmbeddedKeyable o)
<T> List<T>
selectNativeQuery(Class<T> entityClazz, String sql, Map<String,Object> params)
<T> int
update(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> spec, UpdateSpecification<T> updateSpec)
-
-
-
Field Detail
-
txService
@Lazy protected final TransactionService txService
-
-
Constructor Detail
-
JpaDaoImpl
public JpaDaoImpl(Set<javax.persistence.EntityManager> entityManagers, TransactionService txService)
-
-
Method Detail
-
getSupportedEntityManager
protected javax.persistence.EntityManager getSupportedEntityManager(String entityClazz)
-
findById
public <T extends BaseEntity> T findById(String type, Long id)
-
findById
public <T extends BaseEntity> T findById(Class<T> clazz, Long id)
-
getEntityGraph
public <T> javax.persistence.EntityGraph<? super T> getEntityGraph(Class<T> clazz, String name)
- Specified by:
getEntityGraph
in interfaceJpaDao
-
applyGraph
public <T> void applyGraph(Class<T> clazz, javax.persistence.criteria.Root<T> root, String fetchGraph)
- Specified by:
applyGraph
in interfaceJpaDao
-
getList
public <T,X> List<T> getList(Class<T> clazz, javax.persistence.metamodel.SingularAttribute<T,X> name, X value)
-
applyGraph
public <T> void applyGraph(javax.persistence.criteria.Root<T> root, javax.persistence.EntityGraph<? super T> fetchGraph)
- Specified by:
applyGraph
in interfaceJpaDao
-
getJoinType
protected javax.persistence.criteria.JoinType getJoinType(javax.persistence.criteria.FetchParent fetch, String attrName)
-
getJoinType
protected javax.persistence.criteria.JoinType getJoinType(javax.persistence.criteria.From from, String attrName)
-
getListByIds
public <T> List<T> getListByIds(Class<T> clazz, List<Long> ids)
- Specified by:
getListByIds
in interfaceJpaDao
-
getCount
public <T> Long getCount(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> specification)
-
refresh
public void refresh(AbstractEntity o)
-
evict
public <T extends BaseEntity> T evict(T o)
-
delete
public void delete(AbstractEntity o)
-
delete
public <T extends BaseEntity> T delete(Class<T> clazz, Long id)
-
delete
public <T> int delete(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> spec)
-
update
public <T> int update(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> spec, UpdateSpecification<T> updateSpec)
-
saveWithCompositeKey
public void saveWithCompositeKey(EmbeddedKeyable o)
- Specified by:
saveWithCompositeKey
in interfaceJpaDao
-
deleteWithCompositeKey
public void deleteWithCompositeKey(EmbeddedKeyable o)
- Specified by:
deleteWithCompositeKey
in interfaceJpaDao
-
getIds
public <T> List<Long> getIds(Class<T> entityClazz, org.springframework.data.jpa.domain.Specification<T> searchSpec)
-
lock
public void lock(AbstractEntity entity, javax.persistence.LockModeType lockMode, int timeout)
-
lockAndRefresh
public void lockAndRefresh(AbstractEntity entity, int timeout)
- Specified by:
lockAndRefresh
in interfaceJpaDao
-
revert
public void revert(AbstractEntity entity)
-
selectNativeQuery
public <T> List<T> selectNativeQuery(Class<T> entityClazz, String sql, Map<String,Object> params)
- Specified by:
selectNativeQuery
in interfaceJpaDao
-
getList
public <T> List<T> getList(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> specification)
-
getList
public <R,T> List<T> getList(Class<R> rootClass, Class<T> targetClass, Selector<R,T> selector, org.springframework.data.jpa.domain.Specification<R> specification)
-
getPage
public <T> ResultPage<T> getPage(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> specification, PageSpecification page)
-
getStream
@Transactional(propagation=MANDATORY) public <T> Stream<T> getStream(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> specification)
-
getSingleResult
public <T> T getSingleResult(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> specification)
- Specified by:
getSingleResult
in interfaceJpaDao
-
fetchBySpecification
public <T extends BaseEntity> T fetchBySpecification(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> specification)
- Specified by:
fetchBySpecification
in interfaceJpaDao
-
getSingleResultOrNull
public <T> T getSingleResultOrNull(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> specification)
- Specified by:
getSingleResultOrNull
in interfaceJpaDao
-
getFirstResultOrNull
public <T> T getFirstResultOrNull(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> specification)
- Specified by:
getFirstResultOrNull
in interfaceJpaDao
-
exists
public <T> boolean exists(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> specification)
-
applyPaging
protected <T> javax.persistence.TypedQuery<T> applyPaging(javax.persistence.TypedQuery<T> query, PageSpecification page)
-
getPage
public <R,T> ResultPage<T> getPage(Class<R> rootClass, Class<T> targetClass, Selector<R,T> selector, org.springframework.data.jpa.domain.Specification<R> specification, PageSpecification page)
-
getStream
@Transactional(propagation=MANDATORY) public <R,T> Stream<T> getStream(Class<R> rootClass, Class<T> targetClass, Selector<R,T> selector, org.springframework.data.jpa.domain.Specification<R> specification)
-
getSingleResult
public <R,T> T getSingleResult(Class<R> rootClass, Class<T> targetClass, Selector<R,T> selector, org.springframework.data.jpa.domain.Specification<R> specification)
- Specified by:
getSingleResult
in interfaceJpaDao
-
getSingleResultOrNull
public <R,T> T getSingleResultOrNull(Class<R> rootClass, Class<T> targetClass, Selector<R,T> selector, org.springframework.data.jpa.domain.Specification<R> specification)
- Specified by:
getSingleResultOrNull
in interfaceJpaDao
-
getFirstResultOrNull
public <R,T> T getFirstResultOrNull(Class<R> rootClass, Class<T> targetClass, Selector<R,T> selector, org.springframework.data.jpa.domain.Specification<R> specification)
- Specified by:
getFirstResultOrNull
in interfaceJpaDao
-
getTypedQuery
protected <R,T> javax.persistence.TypedQuery<T> getTypedQuery(Class<R> rootClass, Class<T> targetClass, Selector<R,T> selector, org.springframework.data.jpa.domain.Specification<R> specification)
-
asStream
protected <T> Stream<T> asStream(javax.persistence.TypedQuery<T> query)
-
getEntityType
protected javax.persistence.metamodel.EntityType<BaseEntity> getEntityType(String name)
-
getEntityType
public <T> javax.persistence.metamodel.EntityType<T> getEntityType(Class<T> cls)
- Specified by:
getEntityType
in interfaceJpaDao
-
-