Class JpaDaoImpl

  • All Implemented Interfaces:
    JpaDao
    Direct Known Subclasses:
    BaseDAOImpl

    @Repository
    @Primary
    @Transactional
    public class JpaDaoImpl
    extends Object
    implements JpaDao
    • Constructor Detail

      • JpaDaoImpl

        public JpaDaoImpl​(Set<javax.persistence.EntityManager> entityManagers,
                          TransactionService txService)
    • Method Detail

      • getSupportedEntityManager

        protected javax.persistence.EntityManager getSupportedEntityManager​(String entityClazz)
      • getEntityGraph

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

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

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

        public <T> void applyGraph​(javax.persistence.criteria.Root<T> root,
                                   javax.persistence.EntityGraph<? super T> fetchGraph)
        Specified by:
        applyGraph in interface JpaDao
      • 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)
      • 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
      • 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
      • 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
      • 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,
                         javax.persistence.LockModeType lockMode,
                         int timeout)
        Specified by:
        lock 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
      • 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> javax.persistence.TypedQuery<T> applyPaging​(javax.persistence.TypedQuery<T> query,
                                                                  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)
        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> 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 interface JpaDao