Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Extend this class if you intend on implementing EntityRepository with a JPA persistent context.
- *
- * This class requires all sub classes to have a constructor that sets an instance of JpaRepository and the entity's type.
- *
- * @param <I> The class that represents the id of the entity.
- * @param <E> The entity class.
- */
- public abstract class JpaEntityRepository<I,E> implements EntityRepository<I,E>{
- protected final JpaRepository repository;
- protected final Class<E> entityType;
- protected JpaEntityRepository(JpaRepository repository, Class<E> entityType){
- this.repository = repository;
- this.entityType = entityType;
- }
- @Override
- public boolean contains(E entity){
- return repository.contains(entity);
- }
- @Override
- public void detach(E entity){
- repository.detach(entity);
- }
- @Override
- public E find(I id){
- return repository.find(entityType, id);
- }
- @Override
- public void persist(E entity){
- repository.persist(entity);
- }
- @Override
- public void refresh(E entity){
- repository.refresh(entity);
- }
- @Override
- public void remove(E entity){
- repository.remove(entity);
- }
- @Override
- public E merge(E entity){
- return repository.merge(entity);
- }
- }
Add Comment
Please, Sign In to add comment