Package io.beanmapper.spring.web
Class SpringDataEntityFinder
java.lang.Object
io.beanmapper.spring.web.SpringDataEntityFinder
- All Implemented Interfaces:
EntityFinder
The default implementation is based on the Repositories class of Spring Data. It
first looks up the repository. If found, it then calls findOne on the repository.
- Author:
- Robert Bor
-
Constructor Summary
ConstructorDescriptionSpringDataEntityFinder
(org.springframework.context.ApplicationContext applicationContext, javax.persistence.EntityManager entityManager) -
Method Summary
-
Constructor Details
-
SpringDataEntityFinder
public SpringDataEntityFinder(org.springframework.context.ApplicationContext applicationContext, javax.persistence.EntityManager entityManager)
-
-
Method Details
-
findAndDetach
public <T> T findAndDetach(Long id, Class<T> entityClass) throws javax.persistence.EntityNotFoundException Returns the entity on the basis of the entity class and its ID bypassing the Hibernate cache- Specified by:
findAndDetach
in interfaceEntityFinder
- Parameters:
id
- the ID of the entityentityClass
- the class of the entity- Returns:
- the entity if found
- Throws:
javax.persistence.EntityNotFoundException
- if the repository or the entity could not be found
-
find
Returns the entity on the basis of the entity class and its ID.- Specified by:
find
in interfaceEntityFinder
- Parameters:
id
- the ID of the entityentityClass
- the class of the entity- Returns:
- the entity if found
- Throws:
javax.persistence.EntityNotFoundException
- if the repository or the entity could not be found
-