Class JpaDaoImpl

java.lang.Object
org.cxbox.model.core.dao.impl.JpaDaoImpl
All Implemented Interfaces:
JpaDao

@Repository @Primary @Transactional public class JpaDaoImpl extends Object implements JpaDao
  • Field Details

  • Constructor Details

    • JpaDaoImpl

      public JpaDaoImpl(Set<jakarta.persistence.EntityManager> entityManagers, TransactionService txService)
  • Method Details

    • getSupportedEntityManager

      protected jakarta.persistence.EntityManager getSupportedEntityManager(String entityClazz)
    • findById

      public <T extends BaseEntity> T findById(String type, Long id)
      Specified by:
      findById in interface JpaDao
    • findById

      public <T extends BaseEntity> T findById(Class<T> clazz, Long id)
      Specified by:
      findById in interface JpaDao
    • getEntityGraph

      public <T> jakarta.persistence.EntityGraph<? super T> getEntityGraph(Class<T> clazz, String name)
      Specified by:
      getEntityGraph in interface JpaDao
    • applyGraph

      public <T> void applyGraph(Class<T> clazz, jakarta.persistence.criteria.Root<T> root, String fetchGraph)
      Specified by:
      applyGraph in interface JpaDao
    • getList

      public <T, X> List<T> getList(Class<T> clazz, jakarta.persistence.metamodel.SingularAttribute<T,X> name, X value)
      Specified by:
      getList in interface JpaDao
    • applyGraph

      public <T> void applyGraph(jakarta.persistence.criteria.Root<T> root, jakarta.persistence.EntityGraph<? super T> fetchGraph)
      Specified by:
      applyGraph in interface JpaDao
    • getJoinType

      protected jakarta.persistence.criteria.JoinType getJoinType(jakarta.persistence.criteria.FetchParent fetch, String attrName)
    • getJoinType

      protected jakarta.persistence.criteria.JoinType getJoinType(jakarta.persistence.criteria.From from, String attrName)
    • getListByIds

      public <T> List<T> getListByIds(Class<T> clazz, List<Long> ids)
      Specified by:
      getListByIds in interface JpaDao
    • getCount

      public Long getCount(Class<?> clazz)
      Specified by:
      getCount in interface JpaDao
    • getCount

      public <T> Long getCount(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> specification)
      Specified by:
      getCount in interface JpaDao
    • flush

      public void flush()
      Specified by:
      flush in interface JpaDao
    • clear

      public void clear()
      Specified by:
      clear in interface JpaDao
    • refresh

      public void refresh(AbstractEntity o)
      Specified by:
      refresh in interface JpaDao
    • save

      public <T> T save(Object entity)
      Specified by:
      save in interface JpaDao
    • saveAll

      public <T> List<T> saveAll(List<T> entities)
      Specified by:
      saveAll in interface JpaDao
    • evict

      public <T extends BaseEntity> T evict(T o)
      Specified by:
      evict in interface JpaDao
    • delete

      public void delete(AbstractEntity o)
      Specified by:
      delete in interface JpaDao
    • delete

      public <T extends BaseEntity> T delete(Class<T> clazz, Long id)
      Specified by:
      delete in interface JpaDao
    • getList

      public <T> List<T> getList(Class<T> entityClass)
      Specified by:
      getList in interface JpaDao
    • delete

      public <T> int delete(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> spec)
      Specified by:
      delete in interface JpaDao
    • update

      public <T> int update(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> spec, UpdateSpecification<T> updateSpec)
      Specified by:
      update in interface JpaDao
    • saveWithCompositeKey

      public void saveWithCompositeKey(EmbeddedKeyable o)
      Specified by:
      saveWithCompositeKey in interface JpaDao
    • deleteWithCompositeKey

      public void deleteWithCompositeKey(EmbeddedKeyable o)
      Specified by:
      deleteWithCompositeKey in interface JpaDao
    • getIds

      public <T> List<Long> getIds(Class<T> entityClazz, org.springframework.data.jpa.domain.Specification<T> searchSpec)
      Specified by:
      getIds in interface JpaDao
    • lock

      public void lock(AbstractEntity entity, jakarta.persistence.LockModeType lockMode, int timeout)
      Specified by:
      lock in interface JpaDao
    • lockAndRefresh

      public void lockAndRefresh(AbstractEntity entity, int timeout)
      Specified by:
      lockAndRefresh in interface JpaDao
    • revert

      public void revert(AbstractEntity entity)
      Specified by:
      revert in interface JpaDao
    • selectNativeQuery

      public <T> List<T> selectNativeQuery(Class<T> entityClazz, String sql, Map<String,Object> params)
      Specified by:
      selectNativeQuery in interface JpaDao
    • getList

      public <T> List<T> getList(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> specification)
      Specified by:
      getList in interface JpaDao
    • 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)
      Specified by:
      getList in interface JpaDao
    • getPage

      public <T> ResultPage<T> getPage(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> specification, PageSpecification page)
      Specified by:
      getPage in interface JpaDao
    • getStream

      @Transactional(propagation=MANDATORY) public <T> Stream<T> getStream(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> specification)
      Specified by:
      getStream in interface JpaDao
    • getSingleResult

      public <T> T getSingleResult(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> specification)
      Specified by:
      getSingleResult in interface JpaDao
    • fetchBySpecification

      public <T extends BaseEntity> T fetchBySpecification(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> specification)
      Specified by:
      fetchBySpecification in interface JpaDao
    • getSingleResultOrNull

      public <T> T getSingleResultOrNull(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> specification)
      Specified by:
      getSingleResultOrNull in interface JpaDao
    • getFirstResultOrNull

      public <T> T getFirstResultOrNull(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> specification)
      Specified by:
      getFirstResultOrNull in interface JpaDao
    • exists

      public <T> boolean exists(Class<T> entityClass, org.springframework.data.jpa.domain.Specification<T> specification)
      Specified by:
      exists in interface JpaDao
    • applyPaging

      protected <T> jakarta.persistence.TypedQuery<T> applyPaging(jakarta.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)
      Specified by:
      getPage in interface JpaDao
    • 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)
      Specified by:
      getStream in interface JpaDao
    • 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 interface JpaDao
    • 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 interface JpaDao
    • 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 interface JpaDao
    • getTypedQuery

      protected <R, T> jakarta.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(jakarta.persistence.TypedQuery<T> query)
    • getEntityType

      protected jakarta.persistence.metamodel.EntityType<BaseEntity> getEntityType(String name)
    • getEntityType

      public <T> jakarta.persistence.metamodel.EntityType<T> getEntityType(Class<T> cls)
      Specified by:
      getEntityType in interface JpaDao