Class SpringDataEntityFinder

java.lang.Object
io.beanmapper.spring.web.SpringDataEntityFinder
All Implemented Interfaces:
EntityFinder

public class SpringDataEntityFinder extends Object implements 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

    Constructors
    Constructor
    Description
    SpringDataEntityFinder(org.springframework.context.ApplicationContext applicationContext, javax.persistence.EntityManager entityManager)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    find(Long id, Class<T> entityClass)
    Returns the entity on the basis of the entity class and its ID.
    <T> T
    findAndDetach(Long id, Class<T> entityClass)
    Returns the entity on the basis of the entity class and its ID bypassing the Hibernate cache

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 interface EntityFinder
      Parameters:
      id - the ID of the entity
      entityClass - 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

      public <T> T find(Long id, Class<T> entityClass) throws javax.persistence.EntityNotFoundException
      Returns the entity on the basis of the entity class and its ID.
      Specified by:
      find in interface EntityFinder
      Parameters:
      id - the ID of the entity
      entityClass - the class of the entity
      Returns:
      the entity if found
      Throws:
      javax.persistence.EntityNotFoundException - if the repository or the entity could not be found