diff --git a/hibernate-types-52/src/main/java/com/vladmihalcea/spring/repository/HibernateRepository.java b/hibernate-types-52/src/main/java/com/vladmihalcea/spring/repository/HibernateRepository.java index 88bc898ab..c8e85d36c 100644 --- a/hibernate-types-52/src/main/java/com/vladmihalcea/spring/repository/HibernateRepository.java +++ b/hibernate-types-52/src/main/java/com/vladmihalcea/spring/repository/HibernateRepository.java @@ -5,7 +5,7 @@ /** * 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. * @@ -14,54 +14,168 @@ */ public interface HibernateRepository { - //The findAll method will trigger an UnsupportedOperationException - + /** + * 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 methods are meant to save newly created 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 peristAllAndFlush(Iterable entities); - //The merge methods are meant to propagate detached entity state changes - //if they are really needed - + /** + * 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 methods are meant to force the detached entity state changes - + /** + * 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); - } diff --git a/hibernate-types-55/src/main/java/com/vladmihalcea/spring/repository/HibernateRepository.java b/hibernate-types-55/src/main/java/com/vladmihalcea/spring/repository/HibernateRepository.java index 88bc898ab..c8e85d36c 100644 --- a/hibernate-types-55/src/main/java/com/vladmihalcea/spring/repository/HibernateRepository.java +++ b/hibernate-types-55/src/main/java/com/vladmihalcea/spring/repository/HibernateRepository.java @@ -5,7 +5,7 @@ /** * 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. * @@ -14,54 +14,168 @@ */ public interface HibernateRepository { - //The findAll method will trigger an UnsupportedOperationException - + /** + * 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 methods are meant to save newly created 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 peristAllAndFlush(Iterable entities); - //The merge methods are meant to propagate detached entity state changes - //if they are really needed - + /** + * 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 methods are meant to force the detached entity state changes - + /** + * 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); - } diff --git a/hibernate-types-60/src/main/java/com/vladmihalcea/spring/repository/HibernateRepository.java b/hibernate-types-60/src/main/java/com/vladmihalcea/spring/repository/HibernateRepository.java index 88bc898ab..c8e85d36c 100644 --- a/hibernate-types-60/src/main/java/com/vladmihalcea/spring/repository/HibernateRepository.java +++ b/hibernate-types-60/src/main/java/com/vladmihalcea/spring/repository/HibernateRepository.java @@ -5,7 +5,7 @@ /** * 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. * @@ -14,54 +14,168 @@ */ public interface HibernateRepository { - //The findAll method will trigger an UnsupportedOperationException - + /** + * 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 methods are meant to save newly created 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 peristAllAndFlush(Iterable entities); - //The merge methods are meant to propagate detached entity state changes - //if they are really needed - + /** + * 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 methods are meant to force the detached entity state changes - + /** + * 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); - }