Class AbstractEntityManagerHandlerImpl
- java.lang.Object
-
- org.cyclos.impl.utils.persistence.AbstractEntityManagerHandlerImpl
-
- All Implemented Interfaces:
BaseEntityManagerHandler
- Direct Known Subclasses:
EntityManagerHandlerImpl,RawEntityManagerHandlerImpl
public abstract class AbstractEntityManagerHandlerImpl extends Object implements BaseEntityManagerHandler
Base implementation forBaseEntityManagerHandler
-
-
Field Summary
Fields Modifier and Type Field Description protected ConversionHandlerconversionHandlerprotected javax.persistence.EntityManagerentityManagerprotected javax.persistence.EntityManagerFactoryentityManagerFactoryprotected NativeQueryHandlernativeQueryHandler
-
Constructor Summary
Constructors Constructor Description AbstractEntityManagerHandlerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears the underlyingEntityManagerprotected DBQuery<?>createQuery()com.querydsl.jpa.impl.JPADeleteClausedelete(com.querydsl.core.types.EntityPath<?> entity)Returns a delete clausevoiddetach(IEntity entity)Detaches the given entity from the underlying EntityManager<E extends IEntity>
Efind(Class<E> entityClass, Long id)Finds the given entity by idvoidflush()Flushes the underlyingEntityManagerjavax.persistence.EntityManagergetEntityManager()javax.persistence.EntityManagerFactorygetEntityManagerFactory()voidpersist(IEntity entity)Persists the given entityvoidpersist(IEntity entity, boolean flush)Persists the given entity, optionally flushing the underlying entity manager<E extends IEntity>
Erefresh(E entity)Refreshes the current state of the given entity, returning the updated instance.voidremove(IEntity entity)Removes the given entity, flushing the underlying entity managervoidremove(IEntity entity, boolean flush)Removes the given entity, optionally flushing the underlying entity manager<T> DBQuery<T>selectFrom(com.querydsl.core.types.EntityPath<T> from)Creates a new query, assigning the from clause and select clausesDBQuery<?>subQuery(com.querydsl.core.types.EntityPath<?>... from)Creates a new subquery, assigning the from clausecom.querydsl.jpa.impl.JPAUpdateClauseupdate(com.querydsl.core.types.EntityPath<?> entity)Returns an update clause-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.cyclos.impl.utils.persistence.BaseEntityManagerHandler
from
-
-
-
-
Field Detail
-
nativeQueryHandler
@Autowired @Lazy protected NativeQueryHandler nativeQueryHandler
-
entityManagerFactory
@Autowired protected javax.persistence.EntityManagerFactory entityManagerFactory
-
conversionHandler
@Autowired protected ConversionHandler conversionHandler
-
entityManager
@Autowired(required=false) protected javax.persistence.EntityManager entityManager
-
-
Method Detail
-
clear
public void clear()
Description copied from interface:BaseEntityManagerHandlerClears the underlyingEntityManager- Specified by:
clearin interfaceBaseEntityManagerHandler
-
delete
public com.querydsl.jpa.impl.JPADeleteClause delete(com.querydsl.core.types.EntityPath<?> entity)
Description copied from interface:BaseEntityManagerHandlerReturns a delete clause- Specified by:
deletein interfaceBaseEntityManagerHandler
-
detach
public void detach(IEntity entity)
Description copied from interface:BaseEntityManagerHandlerDetaches the given entity from the underlying EntityManager- Specified by:
detachin interfaceBaseEntityManagerHandler
-
find
public <E extends IEntity> E find(Class<E> entityClass, Long id) throws EntityNotFoundException
Description copied from interface:BaseEntityManagerHandlerFinds the given entity by id- Specified by:
findin interfaceBaseEntityManagerHandler- Throws:
EntityNotFoundException
-
flush
public void flush()
Description copied from interface:BaseEntityManagerHandlerFlushes the underlyingEntityManager- Specified by:
flushin interfaceBaseEntityManagerHandler
-
getEntityManager
public javax.persistence.EntityManager getEntityManager()
-
getEntityManagerFactory
public javax.persistence.EntityManagerFactory getEntityManagerFactory()
-
persist
public final void persist(IEntity entity)
Description copied from interface:BaseEntityManagerHandlerPersists the given entity- Specified by:
persistin interfaceBaseEntityManagerHandler
-
persist
public void persist(IEntity entity, boolean flush)
Description copied from interface:BaseEntityManagerHandlerPersists the given entity, optionally flushing the underlying entity manager- Specified by:
persistin interfaceBaseEntityManagerHandler
-
refresh
public <E extends IEntity> E refresh(E entity)
Description copied from interface:BaseEntityManagerHandlerRefreshes the current state of the given entity, returning the updated instance. If the underlyingEntityManagercontains the given entity, will directly refresh it and return the same instance. Otherwise, will find the entity by id.- Specified by:
refreshin interfaceBaseEntityManagerHandler
-
remove
public final void remove(IEntity entity) throws ConstraintViolatedOnRemoveException
Description copied from interface:BaseEntityManagerHandlerRemoves the given entity, flushing the underlying entity manager- Specified by:
removein interfaceBaseEntityManagerHandler- Throws:
ConstraintViolatedOnRemoveException
-
remove
public void remove(IEntity entity, boolean flush) throws ConstraintViolatedOnRemoveException
Description copied from interface:BaseEntityManagerHandlerRemoves the given entity, optionally flushing the underlying entity manager- Specified by:
removein interfaceBaseEntityManagerHandler- Throws:
ConstraintViolatedOnRemoveException
-
selectFrom
public <T> DBQuery<T> selectFrom(com.querydsl.core.types.EntityPath<T> from)
Description copied from interface:BaseEntityManagerHandlerCreates a new query, assigning the from clause and select clauses- Specified by:
selectFromin interfaceBaseEntityManagerHandler
-
subQuery
public DBQuery<?> subQuery(com.querydsl.core.types.EntityPath<?>... from)
Description copied from interface:BaseEntityManagerHandlerCreates a new subquery, assigning the from clause- Specified by:
subQueryin interfaceBaseEntityManagerHandler
-
update
public com.querydsl.jpa.impl.JPAUpdateClause update(com.querydsl.core.types.EntityPath<?> entity)
Description copied from interface:BaseEntityManagerHandlerReturns an update clause- Specified by:
updatein interfaceBaseEntityManagerHandler
-
createQuery
protected DBQuery<?> createQuery()
-
-