All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.hypersistence.utils.spring.repository.HibernateRepository Maven / Gradle / Ivy

There is a newer version: 3.9.0
Show newest version
package io.hypersistence.utils.spring.repository;

import java.util.List;

/**
 * The {@code HibernateRepository} fixes the problems that the default Spring Data {@code JpaRepository}
 * suffers from.
 * 

* For more details about how to use it, check out this article. * * @author Vlad Mihalcea * @version 2.17.0 */ public interface HibernateRepository { /** * The findAll method is a terrible Anti-Pattern. *

* For more details about why you should not use the {@code findAll} method by default, * check out this article. * * @return all the records from the database table this entity is mapped to */ @Deprecated List findAll(); //The save methods will trigger an UnsupportedOperationException /** * The save method should be avoided. *

* For more details about how to use it, check out this article. */ @Deprecated S save(S entity); /** * The save method should be avoided. *

* For more details about how to use it, check out this article. */ @Deprecated List saveAll(Iterable entities); /** * The saveAndFlush method should be avoided. *

* For more details about how to use it, check out this article. */ @Deprecated S saveAndFlush(S entity); /** * The saveAllAndFlush method should be avoided. *

* For more details about how to use it, check out this article. */ @Deprecated List saveAllAndFlush(Iterable entities); /** * The persist method allows you to pass the provided entity to the {@code persist} method of the * underlying JPA {@code EntityManager}. * * @param entity entity to persist * @param entity type * @return entity */ S persist(S entity); /** * The persistAndFlush method allows you to pass the provided entity to the {@code persist} method of the * underlying JPA {@code EntityManager} and call {@code flush} afterwards. * * @param entity entity to persist * @param entity type * @return entity */ S persistAndFlush(S entity); /** * The persistAll method allows you to pass the provided entities to the {@code persist} method of the * underlying JPA {@code EntityManager}. * * @param entities entities to persist * @param entity type * @return entities */ List persistAll(Iterable entities); /** * The persistAll method allows you to pass the provided entities to the {@code persist} method of the * underlying JPA {@code EntityManager} and call {@code flush} afterwards. * * @param entities entities to persist * @param entity type * @return entities */ List persistAllAndFlush(Iterable entities); /** * The persist method allows you to pass the provided entity to the {@code merge} method of the * underlying JPA {@code EntityManager}. * * @param entity entity to merge * @param entity type * @return entity */ S merge(S entity); /** * The mergeAndFlush method allows you to pass the provided entity to the {@code merge} method of the * underlying JPA {@code EntityManager} and call {@code flush} afterwards. * * @param entity entity to merge * @param entity type * @return entity */ S mergeAndFlush(S entity); /** * The mergeAll method allows you to pass the provided entities to the {@code merge} method of the * underlying JPA {@code EntityManager}. * * @param entities entities to merge * @param entity type * @return entities */ List mergeAll(Iterable entities); /** * The mergeAllAndFlush method allows you to pass the provided entities to the {@code merge} method of the * underlying JPA {@code EntityManager} and call {@code flush} afterwards. * * @param entities entities to persist * @param entity type * @return entities */ List mergeAllAndFlush(Iterable entities); /** * The update method allows you to pass the provided entity to the {@code update} method of the * underlying JPA {@code EntityManager}. * * @param entity entity to update * @param entity type * @return entity */ S update(S entity); /** * The updateAndFlush method allows you to pass the provided entity to the {@code update} method of the * underlying JPA {@code EntityManager} and call {@code flush} afterwards. * * @param entity entity to update * @param entity type * @return entity */ S updateAndFlush(S entity); /** * The updateAll method allows you to pass the provided entities to the {@code update} method of the * underlying JPA {@code EntityManager}. * * @param entities entities to update * @param entity type * @return entities */ List updateAll(Iterable entities); /** * The updateAllAndFlush method allows you to pass the provided entities to the {@code update} method of the * underlying JPA {@code EntityManager} and call {@code flush} afterwards. * * @param entities entities to update * @param entity type * @return entities */ List updateAllAndFlush(Iterable entities); }