diff --git a/persistence-modules/hibernate-enterprise/README.md b/persistence-modules/hibernate-enterprise/README.md
index c5606d0970..1a86c32afa 100644
--- a/persistence-modules/hibernate-enterprise/README.md
+++ b/persistence-modules/hibernate-enterprise/README.md
@@ -9,4 +9,5 @@ This module contains articles about enterprise concerns such as Multitenancy, Er
- [Hibernate Aggregate Functions](https://www.baeldung.com/hibernate-aggregate-functions)
- [Common Hibernate Exceptions](https://www.baeldung.com/hibernate-exceptions)
- [Hibernate Error “Not all named parameters have been set”](https://www.baeldung.com/hibernate-error-named-parameters-not-set)
-- [Various Logging Levels in Hibernate](https://www.baeldung.com/hibernate-logging-levels)
\ No newline at end of file
+- [Various Logging Levels in Hibernate](https://www.baeldung.com/hibernate-logging-levels)
+- [Hibernate: save, persist, update, merge, saveOrUpdate](https://www.baeldung.com/hibernate-save-persist-update-merge-saveorupdate)
\ No newline at end of file
diff --git a/persistence-modules/hibernate-enterprise/pom.xml b/persistence-modules/hibernate-enterprise/pom.xml
index ae58e409c4..c088cc1eca 100644
--- a/persistence-modules/hibernate-enterprise/pom.xml
+++ b/persistence-modules/hibernate-enterprise/pom.xml
@@ -61,13 +61,25 @@
${byte-buddy.version}
test
+
+ org.hsqldb
+ hsqldb
+ ${hsqldb.version}
+ test
+
- geodb-repo
- GeoDB repository
- http://repo.boundlessgeo.com/main/
+ osgeo
+ OSGeo Release Repository
+ https://repo.osgeo.org/repository/release/
+
+ false
+
+
+ true
+
@@ -77,6 +89,7 @@
2.2.3
3.8.0
0.9
+ 2.3.4
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Person.java b/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/persistence/model/Person.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Person.java
rename to persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/persistence/model/Person.java
diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/save/SaveMethodsIntegrationTest.java b/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/persistence/save/SaveMethodsIntegrationTest.java
similarity index 79%
rename from persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/save/SaveMethodsIntegrationTest.java
rename to persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/persistence/save/SaveMethodsIntegrationTest.java
index ef83af3a0d..8c571428b4 100644
--- a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/save/SaveMethodsIntegrationTest.java
+++ b/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/persistence/save/SaveMethodsIntegrationTest.java
@@ -1,6 +1,14 @@
package com.baeldung.persistence.save;
-import com.baeldung.persistence.model.Person;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+
+import javax.persistence.PersistenceException;
+
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
@@ -8,9 +16,13 @@ import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.service.ServiceRegistry;
-import org.junit.*;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
-import static org.junit.Assert.*;
+import com.baeldung.persistence.model.Person;
/**
* Testing specific implementation details for different methods:
@@ -21,12 +33,19 @@ public class SaveMethodsIntegrationTest {
private static SessionFactory sessionFactory;
private Session session;
+ private boolean doNotCommit = false;
@BeforeClass
public static void beforeTests() {
- Configuration configuration = new Configuration().addAnnotatedClass(Person.class).setProperty("hibernate.dialect", HSQLDialect.class.getName()).setProperty("hibernate.connection.driver_class", org.hsqldb.jdbcDriver.class.getName())
- .setProperty("hibernate.connection.url", "jdbc:hsqldb:mem:test").setProperty("hibernate.connection.username", "sa").setProperty("hibernate.connection.password", "").setProperty("hibernate.hbm2ddl.auto", "update");
- ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build();
+ Configuration configuration = new Configuration().addAnnotatedClass(Person.class)
+ .setProperty("hibernate.dialect", HSQLDialect.class.getName())
+ .setProperty("hibernate.connection.driver_class", org.hsqldb.jdbcDriver.class.getName())
+ .setProperty("hibernate.connection.url", "jdbc:hsqldb:mem:test")
+ .setProperty("hibernate.connection.username", "sa")
+ .setProperty("hibernate.connection.password", "")
+ .setProperty("hibernate.hbm2ddl.auto", "update");
+ ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties())
+ .build();
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
}
@@ -34,6 +53,7 @@ public class SaveMethodsIntegrationTest {
public void setUp() {
session = sessionFactory.openSession();
session.beginTransaction();
+ doNotCommit = false;
}
@Test
@@ -43,7 +63,8 @@ public class SaveMethodsIntegrationTest {
person.setName("John");
session.persist(person);
- session.getTransaction().commit();
+ session.getTransaction()
+ .commit();
session.close();
session = sessionFactory.openSession();
@@ -68,15 +89,33 @@ public class SaveMethodsIntegrationTest {
assertEquals(id1, id2);
}
- @Test(expected = HibernateException.class)
+ @Test(expected = PersistenceException.class)
public void whenPersistDetached_thenThrowsException() {
+ doNotCommit = true;
+
Person person = new Person();
person.setName("John");
session.persist(person);
session.evict(person);
-
+
session.persist(person);
+ }
+
+ @Test
+ public void whenMergeDetached_thenEntityUpdatedFromDatabase() {
+
+ Person person = new Person();
+ person.setName("John");
+ session.save(person);
+ session.flush();
+ session.evict(person);
+
+ person.setName("Mary");
+ Person mergedPerson = (Person) session.merge(person);
+
+ assertNotSame(person, mergedPerson);
+ assertEquals("Mary", mergedPerson.getName());
}
@@ -92,7 +131,8 @@ public class SaveMethodsIntegrationTest {
assertNotNull(id);
- session.getTransaction().commit();
+ session.getTransaction()
+ .commit();
session.close();
assertEquals(id, person.getId());
@@ -128,22 +168,6 @@ public class SaveMethodsIntegrationTest {
}
- @Test
- public void whenMergeDetached_thenEntityUpdatedFromDatabase() {
-
- Person person = new Person();
- person.setName("John");
- session.save(person);
- session.evict(person);
-
- person.setName("Mary");
- Person mergedPerson = (Person) session.merge(person);
-
- assertNotSame(person, mergedPerson);
- assertEquals("Mary", mergedPerson.getName());
-
- }
-
@Test
public void whenMergeTransient_thenNewEntitySavedToDatabase() {
@@ -151,7 +175,8 @@ public class SaveMethodsIntegrationTest {
person.setName("John");
Person mergedPerson = (Person) session.merge(person);
- session.getTransaction().commit();
+ session.getTransaction()
+ .commit();
session.beginTransaction();
assertNull(person.getId());
@@ -227,7 +252,8 @@ public class SaveMethodsIntegrationTest {
person.setName("John");
session.saveOrUpdate(person);
- session.getTransaction().commit();
+ session.getTransaction()
+ .commit();
session.close();
session = sessionFactory.openSession();
@@ -250,7 +276,10 @@ public class SaveMethodsIntegrationTest {
@After
public void tearDown() {
- session.getTransaction().commit();
+ if (!doNotCommit) {
+ session.getTransaction()
+ .commit();
+ }
session.close();
}
diff --git a/persistence-modules/pom.xml b/persistence-modules/pom.xml
index 590e5da76e..05ef14f188 100644
--- a/persistence-modules/pom.xml
+++ b/persistence-modules/pom.xml
@@ -81,8 +81,7 @@
spring-data-redis
spring-data-solr
spring-hibernate-3
- spring-hibernate-5
- spring-hibernate4
+ spring-hibernate-5
spring-jpa
spring-jpa-2
spring-jdbc
diff --git a/persistence-modules/spring-data-jpa-query-2/README.md b/persistence-modules/spring-data-jpa-query-2/README.md
index fdb4ce3db7..bdc8d7cb32 100644
--- a/persistence-modules/spring-data-jpa-query-2/README.md
+++ b/persistence-modules/spring-data-jpa-query-2/README.md
@@ -6,6 +6,12 @@ This module contains articles about querying data using Spring Data JPA
- [Spring Data JPA @Query Annotation](https://www.baeldung.com/spring-data-jpa-query)
- [Use Criteria Queries in a Spring Data Application](https://www.baeldung.com/spring-data-criteria-queries)
- [Query Entities by Dates and Times with Spring Data JPA](https://www.baeldung.com/spring-data-jpa-query-by-date)
+- [Hibernate Pagination](https://www.baeldung.com/hibernate-pagination)
+- [Sorting with Hibernate](https://www.baeldung.com/hibernate-sort)
+- [Stored Procedures with Hibernate](https://www.baeldung.com/stored-procedures-with-hibernate-tutorial)
+- [Eager/Lazy Loading In Hibernate](https://www.baeldung.com/hibernate-lazy-eager-loading)
+- [Auditing with JPA, Hibernate, and Spring Data JPA](https://www.baeldung.com/database-auditing-jpa)
+
- More articles: [[<-- prev]](../spring-data-jpa-query)
### Eclipse Config
diff --git a/persistence-modules/spring-data-jpa-query-2/pom.xml b/persistence-modules/spring-data-jpa-query-2/pom.xml
index 231640284e..abac7b28da 100644
--- a/persistence-modules/spring-data-jpa-query-2/pom.xml
+++ b/persistence-modules/spring-data-jpa-query-2/pom.xml
@@ -18,6 +18,10 @@
org.springframework.boot
spring-boot-starter-data-jpa
+
+ org.springframework.security
+ spring-security-core
+
com.h2database
@@ -28,6 +32,55 @@
com.fasterxml.jackson.core
jackson-databind
+
+
+ org.hibernate
+ hibernate-envers
+
+
+ javax.transaction
+ jta
+ ${jta.version}
+
+
+ mysql
+ mysql-connector-java
+
+
+ com.google.guava
+ guava
+ ${guava.version}
+
+
+ org.apache.tomcat
+ tomcat-dbcp
+ ${tomcat-dbcp.version}
+
+
+ org.hibernate
+ hibernate-core
+ ${hibernate.version}
+
+
+ org.hibernate
+ hibernate-envers
+ ${hibernate.version}
+
+
+ org.springframework
+ spring-test
+ test
+
+
+ org.springframework.security
+ spring-security-test
+ test
+
+
+ org.hsqldb
+ hsqldb
+ test
+
@@ -35,5 +88,10 @@
2.22.2
5.6.2
4.13
+ 9.0.0.M26
+ 1.1
+ 21.0
+
+ 5.2.10.Final
\ No newline at end of file
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/spring/PersistenceConfig.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/config/PersistenceConfig.java
similarity index 95%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/spring/PersistenceConfig.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/config/PersistenceConfig.java
index 4927c9957c..a0d70ed006 100644
--- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/spring/PersistenceConfig.java
+++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/config/PersistenceConfig.java
@@ -1,4 +1,4 @@
-package com.baeldung.spring;
+package com.baeldung.config;
import java.util.Properties;
@@ -15,8 +15,8 @@ import org.springframework.dao.annotation.PersistenceExceptionTranslationPostPro
import org.springframework.data.domain.AuditorAware;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
-import org.springframework.orm.hibernate4.HibernateTransactionManager;
-import org.springframework.orm.hibernate4.LocalSessionFactoryBean;
+import org.springframework.orm.hibernate5.HibernateTransactionManager;
+import org.springframework.orm.hibernate5.LocalSessionFactoryBean;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
@@ -47,7 +47,7 @@ import com.google.common.base.Preconditions;
@Configuration
@EnableTransactionManagement
-@EnableJpaRepositories(basePackages = { "com.baeldung.persistence" }, transactionManagerRef = "jpaTransactionManager")
+@EnableJpaRepositories(basePackages = { "com.baeldung.persistence" }, transactionManagerRef = "jpaTransactionManager", entityManagerFactoryRef = "jpaEntityManager")
@EnableJpaAuditing(auditorAwareRef = "auditorProvider")
@PropertySource({ "classpath:persistence-h2.properties" })
@ComponentScan({ "com.baeldung.persistence" })
@@ -75,7 +75,7 @@ public class PersistenceConfig {
return sessionFactory;
}
- @Bean
+ @Bean("jpaEntityManager")
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
final LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
emf.setDataSource(restDataSource());
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/spring/PersistenceXmlConfig.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/config/PersistenceXmlConfig.java
similarity index 94%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/spring/PersistenceXmlConfig.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/config/PersistenceXmlConfig.java
index 9cbeb8e1f8..388494b21a 100644
--- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/spring/PersistenceXmlConfig.java
+++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/config/PersistenceXmlConfig.java
@@ -1,4 +1,4 @@
-package com.baeldung.spring;
+package com.baeldung.config;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/audit/AuditorAwareImpl.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/audit/AuditorAwareImpl.java
similarity index 80%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/audit/AuditorAwareImpl.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/audit/AuditorAwareImpl.java
index 7aef08b2ce..5dd12e6841 100644
--- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/audit/AuditorAwareImpl.java
+++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/audit/AuditorAwareImpl.java
@@ -9,11 +9,10 @@ import org.springframework.security.core.context.SecurityContextHolder;
public class AuditorAwareImpl implements AuditorAware {
@Override
- public String getCurrentAuditor() {
+ public Optional getCurrentAuditor() {
return Optional.ofNullable(SecurityContextHolder.getContext())
.map(e -> e.getAuthentication())
- .map(Authentication::getName)
- .orElse(null);
+ .map(Authentication::getName);
}
}
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/model/OrderDetail.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/model/OrderDetail.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/model/OrderDetail.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/model/OrderDetail.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/model/UserEager.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/model/UserEager.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/model/UserEager.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/model/UserEager.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/model/UserLazy.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/model/UserLazy.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/model/UserLazy.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/model/UserLazy.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/util/HibernateUtil.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/util/HibernateUtil.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/util/HibernateUtil.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/util/HibernateUtil.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/view/FetchingAppView.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/view/FetchingAppView.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/view/FetchingAppView.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/view/FetchingAppView.java
diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookRepository.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookRepository.java
deleted file mode 100644
index 48620f4ff1..0000000000
--- a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookRepository.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.baeldung.persistence.dao;
-
-import com.baeldung.persistence.model.Book;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
-
-public interface BookRepository extends JpaRepository, BookRepositoryCustom, JpaSpecificationExecutor {
-
-}
diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookRepositoryCustom.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookRepositoryCustom.java
deleted file mode 100644
index eda34542df..0000000000
--- a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookRepositoryCustom.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.baeldung.persistence.dao;
-
-import com.baeldung.persistence.model.Book;
-
-import java.util.List;
-
-public interface BookRepositoryCustom {
-
- List findBooksByAuthorNameAndTitle(String authorName, String title);
-
-}
diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookRepositoryImpl.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookRepositoryImpl.java
deleted file mode 100644
index 7f5bedd018..0000000000
--- a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookRepositoryImpl.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package com.baeldung.persistence.dao;
-
-import com.baeldung.persistence.model.Book;
-import org.springframework.stereotype.Repository;
-
-import javax.persistence.EntityManager;
-import javax.persistence.TypedQuery;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Predicate;
-import javax.persistence.criteria.Root;
-import java.util.ArrayList;
-import java.util.List;
-
-@Repository
-public class BookRepositoryImpl implements BookRepositoryCustom {
-
- private EntityManager em;
-
- public BookRepositoryImpl(EntityManager em) {
- this.em = em;
- }
-
- @Override
- public List findBooksByAuthorNameAndTitle(String authorName, String title) {
- CriteriaBuilder cb = em.getCriteriaBuilder();
- CriteriaQuery cq = cb.createQuery(Book.class);
-
- Root book = cq.from(Book.class);
- List predicates = new ArrayList<>();
-
- if (authorName != null) {
- predicates.add(cb.equal(book.get("author"), authorName));
- }
- if (title != null) {
- predicates.add(cb.like(book.get("title"), "%" + title + "%"));
- }
- cq.where(predicates.toArray(new Predicate[0]));
-
- TypedQuery query = em.createQuery(cq);
- return query.getResultList();
- }
-
-}
diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookService.java
deleted file mode 100644
index 4165cd8eb9..0000000000
--- a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookService.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.baeldung.persistence.dao;
-
-import com.baeldung.persistence.model.Book;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-
-import static com.baeldung.persistence.dao.BookSpecifications.hasAuthor;
-import static com.baeldung.persistence.dao.BookSpecifications.titleContains;
-import static org.springframework.data.jpa.domain.Specification.where;
-
-@Service
-public class BookService {
-
- private BookRepository bookRepository;
-
- public BookService(BookRepository bookRepository) {
- this.bookRepository = bookRepository;
- }
-
- public List query(String author, String title) {
- return bookRepository.findAll(where(hasAuthor(author)).and(titleContains(title)));
- }
-
-}
diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookSpecifications.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookSpecifications.java
deleted file mode 100644
index 16646a5b4b..0000000000
--- a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookSpecifications.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.baeldung.persistence.dao;
-
-import com.baeldung.persistence.model.Book;
-import org.springframework.data.jpa.domain.Specification;
-
-public class BookSpecifications {
-
- public static Specification hasAuthor(String author) {
- return (book, cq, cb) -> cb.equal(book.get("author"), author);
- }
-
- public static Specification titleContains(String title) {
- return (book, cq, cb) -> cb.like(book.get("title"), "%" + title + "%");
- }
-
-}
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IBarAuditableDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IBarAuditableDao.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IBarAuditableDao.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IBarAuditableDao.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IBarCrudRepository.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IBarCrudRepository.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IBarCrudRepository.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IBarCrudRepository.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IBarDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IBarDao.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IBarDao.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IBarDao.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IChildDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IChildDao.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IChildDao.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IChildDao.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IFooAuditableDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IFooAuditableDao.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IFooAuditableDao.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IFooAuditableDao.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IFooDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IFooDao.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IFooDao.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IFooDao.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IParentDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IParentDao.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IParentDao.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IParentDao.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/AbstractDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/AbstractDao.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/AbstractDao.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/AbstractDao.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateAuditableDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateAuditableDao.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateAuditableDao.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateAuditableDao.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateDao.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateDao.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateDao.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/AbstractJpaDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/AbstractJpaDao.java
similarity index 96%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/AbstractJpaDao.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/AbstractJpaDao.java
index 69f8e58c25..79bdd86658 100644
--- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/AbstractJpaDao.java
+++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/AbstractJpaDao.java
@@ -12,7 +12,7 @@ import javax.persistence.criteria.Root;
public class AbstractJpaDao extends AbstractDao implements IOperations {
- @PersistenceContext
+ @PersistenceContext(unitName = "jpaEntityManager")
private EntityManager em;
// API
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/GenericHibernateDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/GenericHibernateDao.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/GenericHibernateDao.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/GenericHibernateDao.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/IAuditOperations.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/IAuditOperations.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/IAuditOperations.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/IAuditOperations.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/IGenericDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/IGenericDao.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/IGenericDao.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/IGenericDao.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/IOperations.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/IOperations.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/IOperations.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/IOperations.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/BarAuditableDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/BarAuditableDao.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/BarAuditableDao.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/BarAuditableDao.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/BarDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/BarDao.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/BarDao.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/BarDao.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/BarJpaDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/BarJpaDao.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/BarJpaDao.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/BarJpaDao.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/ChildDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/ChildDao.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/ChildDao.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/ChildDao.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/FooAuditableDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/FooAuditableDao.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/FooAuditableDao.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/FooAuditableDao.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/FooDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/FooDao.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/FooDao.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/FooDao.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/ParentDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/ParentDao.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/ParentDao.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/ParentDao.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Bar.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Bar.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Bar.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Bar.java
diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Book.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Book.java
deleted file mode 100644
index 507043dd56..0000000000
--- a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Book.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.baeldung.persistence.model;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-
-@Entity
-public class Book {
-
- @Id
- private Long id;
-
- private String title;
-
- private String author;
-
- public Long getId() {
- return id;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public String getAuthor() {
- return author;
- }
-
- public void setAuthor(String author) {
- this.author = author;
- }
-
-}
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Child.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Child.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Child.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Child.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Foo.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Foo.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Foo.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Foo.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Parent.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Parent.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Parent.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Parent.java
diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Person.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Person.java
new file mode 100644
index 0000000000..6a95a7acf5
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Person.java
@@ -0,0 +1,31 @@
+package com.baeldung.persistence.model;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+@Entity
+public class Person {
+
+ @Id
+ @GeneratedValue
+ private Long id;
+
+ private String name;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IBarAuditableService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IBarAuditableService.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IBarAuditableService.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IBarAuditableService.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IBarService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IBarService.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IBarService.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IBarService.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IChildService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IChildService.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IChildService.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IChildService.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IFooAuditableService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IFooAuditableService.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IFooAuditableService.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IFooAuditableService.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IFooService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IFooService.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IFooService.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IFooService.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IParentService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IParentService.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IParentService.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IParentService.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractHibernateAuditableService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractHibernateAuditableService.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractHibernateAuditableService.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractHibernateAuditableService.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractHibernateService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractHibernateService.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractHibernateService.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractHibernateService.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractJpaService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractJpaService.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractJpaService.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractJpaService.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractService.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractService.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractService.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractSpringDataJpaService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractSpringDataJpaService.java
similarity index 86%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractSpringDataJpaService.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractSpringDataJpaService.java
index cef483e6bf..73fe27e9ec 100644
--- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractSpringDataJpaService.java
+++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractSpringDataJpaService.java
@@ -2,6 +2,7 @@ package com.baeldung.persistence.service.common;
import java.io.Serializable;
import java.util.List;
+import java.util.Optional;
import com.baeldung.persistence.dao.common.IOperations;
import org.springframework.data.repository.CrudRepository;
@@ -14,7 +15,8 @@ public abstract class AbstractSpringDataJpaService imple
@Override
public T findOne(final long id) {
- return getDao().findOne(Long.valueOf(id));
+ Optional opt = getDao().findById(Long.valueOf(id));
+ return opt.get();
}
@Override
@@ -39,7 +41,7 @@ public abstract class AbstractSpringDataJpaService imple
@Override
public void deleteById(final long entityId) {
- getDao().delete(Long.valueOf(entityId));
+ getDao().deleteById(Long.valueOf(entityId));
}
protected abstract CrudRepository getDao();
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/BarAuditableService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/BarAuditableService.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/BarAuditableService.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/BarAuditableService.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/BarJpaService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/BarJpaService.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/BarJpaService.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/BarJpaService.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/BarService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/BarService.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/BarService.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/BarService.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/BarSpringDataJpaService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/BarSpringDataJpaService.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/BarSpringDataJpaService.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/BarSpringDataJpaService.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/ChildService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/ChildService.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/ChildService.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/ChildService.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/FooAuditableService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/FooAuditableService.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/FooAuditableService.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/FooAuditableService.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/FooService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/FooService.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/FooService.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/FooService.java
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/ParentService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/ParentService.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/ParentService.java
rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/ParentService.java
diff --git a/persistence-modules/spring-hibernate4/src/main/resources/fetching.cfg.xml b/persistence-modules/spring-data-jpa-query-2/src/main/resources/fetching.cfg.xml
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/resources/fetching.cfg.xml
rename to persistence-modules/spring-data-jpa-query-2/src/main/resources/fetching.cfg.xml
diff --git a/persistence-modules/spring-hibernate4/src/main/resources/fetchingLazy.cfg.xml b/persistence-modules/spring-data-jpa-query-2/src/main/resources/fetchingLazy.cfg.xml
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/resources/fetchingLazy.cfg.xml
rename to persistence-modules/spring-data-jpa-query-2/src/main/resources/fetchingLazy.cfg.xml
diff --git a/persistence-modules/spring-hibernate4/src/main/resources/fetching_create_queries.sql b/persistence-modules/spring-data-jpa-query-2/src/main/resources/fetching_create_queries.sql
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/resources/fetching_create_queries.sql
rename to persistence-modules/spring-data-jpa-query-2/src/main/resources/fetching_create_queries.sql
diff --git a/persistence-modules/spring-hibernate4/src/main/resources/hibernate4Config.xml b/persistence-modules/spring-data-jpa-query-2/src/main/resources/hibernate5Config.xml
similarity index 92%
rename from persistence-modules/spring-hibernate4/src/main/resources/hibernate4Config.xml
rename to persistence-modules/spring-data-jpa-query-2/src/main/resources/hibernate5Config.xml
index ca507802cd..bbb61cb3e0 100644
--- a/persistence-modules/spring-hibernate4/src/main/resources/hibernate4Config.xml
+++ b/persistence-modules/spring-data-jpa-query-2/src/main/resources/hibernate5Config.xml
@@ -7,7 +7,7 @@
-
+
@@ -21,11 +21,11 @@
-
+
-
+
diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/resources/hibernate5Configuration.xml b/persistence-modules/spring-data-jpa-query-2/src/main/resources/hibernate5Configuration.xml
new file mode 100644
index 0000000000..1870cfb917
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-query-2/src/main/resources/hibernate5Configuration.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+ ${hibernate.hbm2ddl.auto}
+ ${hibernate.dialect}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/persistence-modules/spring-hibernate4/src/main/resources/immutable.cfg.xml b/persistence-modules/spring-data-jpa-query-2/src/main/resources/immutable.cfg.xml
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/resources/immutable.cfg.xml
rename to persistence-modules/spring-data-jpa-query-2/src/main/resources/immutable.cfg.xml
diff --git a/persistence-modules/spring-hibernate4/src/main/resources/insert_statements.sql b/persistence-modules/spring-data-jpa-query-2/src/main/resources/insert_statements.sql
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/resources/insert_statements.sql
rename to persistence-modules/spring-data-jpa-query-2/src/main/resources/insert_statements.sql
diff --git a/persistence-modules/spring-hibernate4/src/main/resources/logback.xml b/persistence-modules/spring-data-jpa-query-2/src/main/resources/logback.xml
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/resources/logback.xml
rename to persistence-modules/spring-data-jpa-query-2/src/main/resources/logback.xml
diff --git a/persistence-modules/spring-hibernate4/src/main/resources/persistence-mysql.properties b/persistence-modules/spring-data-jpa-query-2/src/main/resources/persistence-mysql.properties
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/resources/persistence-mysql.properties
rename to persistence-modules/spring-data-jpa-query-2/src/main/resources/persistence-mysql.properties
diff --git a/persistence-modules/spring-hibernate4/src/main/resources/stored_procedure.sql b/persistence-modules/spring-data-jpa-query-2/src/main/resources/stored_procedure.sql
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/resources/stored_procedure.sql
rename to persistence-modules/spring-data-jpa-query-2/src/main/resources/stored_procedure.sql
diff --git a/persistence-modules/spring-hibernate4/src/main/resources/webSecurityConfig.xml b/persistence-modules/spring-data-jpa-query-2/src/main/resources/webSecurityConfig.xml
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/main/resources/webSecurityConfig.xml
rename to persistence-modules/spring-data-jpa-query-2/src/main/resources/webSecurityConfig.xml
diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/hibernate/fetching/HibernateFetchingIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/hibernate/fetching/HibernateFetchingIntegrationTest.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/test/java/com/baeldung/hibernate/fetching/HibernateFetchingIntegrationTest.java
rename to persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/hibernate/fetching/HibernateFetchingIntegrationTest.java
diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/IntegrationTestSuite.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/IntegrationTestSuite.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/IntegrationTestSuite.java
rename to persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/IntegrationTestSuite.java
diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/AuditTestSuite.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/AuditTestSuite.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/AuditTestSuite.java
rename to persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/AuditTestSuite.java
diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/EnversFooBarAuditIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/EnversFooBarAuditIntegrationTest.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/EnversFooBarAuditIntegrationTest.java
rename to persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/EnversFooBarAuditIntegrationTest.java
diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/JPABarAuditIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/JPABarAuditIntegrationTest.java
similarity index 98%
rename from persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/JPABarAuditIntegrationTest.java
rename to persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/JPABarAuditIntegrationTest.java
index 733074a6a3..f591773cde 100644
--- a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/JPABarAuditIntegrationTest.java
+++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/JPABarAuditIntegrationTest.java
@@ -47,6 +47,7 @@ public class JPABarAuditIntegrationTest {
private IBarService barService;
@Autowired
+ @Qualifier("jpaEntityManager")
private EntityManagerFactory entityManagerFactory;
private EntityManager em;
diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/SpringDataJPABarAuditIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/SpringDataJPABarAuditIntegrationTest.java
similarity index 98%
rename from persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/SpringDataJPABarAuditIntegrationTest.java
rename to persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/SpringDataJPABarAuditIntegrationTest.java
index 18227abd28..0603067810 100644
--- a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/SpringDataJPABarAuditIntegrationTest.java
+++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/SpringDataJPABarAuditIntegrationTest.java
@@ -46,6 +46,7 @@ public class SpringDataJPABarAuditIntegrationTest {
private IBarService barService;
@Autowired
+ @Qualifier("jpaEntityManager")
private EntityManagerFactory entityManagerFactory;
private EntityManager em;
diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/hibernate/FooFixtures.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooFixtures.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/hibernate/FooFixtures.java
rename to persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooFixtures.java
diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/hibernate/FooPaginationPersistenceIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooPaginationPersistenceIntegrationTest.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/hibernate/FooPaginationPersistenceIntegrationTest.java
rename to persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooPaginationPersistenceIntegrationTest.java
diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/hibernate/FooSortingPersistenceIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooSortingPersistenceIntegrationTest.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/hibernate/FooSortingPersistenceIntegrationTest.java
rename to persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooSortingPersistenceIntegrationTest.java
diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/service/FooServiceBasicPersistenceIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/service/FooServiceBasicPersistenceIntegrationTest.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/service/FooServiceBasicPersistenceIntegrationTest.java
rename to persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/service/FooServiceBasicPersistenceIntegrationTest.java
diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java
rename to persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java
diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/service/FooStoredProceduresLiveTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/service/FooStoredProceduresLiveTest.java
similarity index 98%
rename from persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/service/FooStoredProceduresLiveTest.java
rename to persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/service/FooStoredProceduresLiveTest.java
index d9353f1ad1..8bf33c4110 100644
--- a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/service/FooStoredProceduresLiveTest.java
+++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/service/FooStoredProceduresLiveTest.java
@@ -21,8 +21,8 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
+import com.baeldung.config.PersistenceConfig;
import com.baeldung.persistence.model.Foo;
-import com.baeldung.spring.PersistenceConfig;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class)
diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/service/ParentServicePersistenceIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/service/ParentServicePersistenceIntegrationTest.java
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/service/ParentServicePersistenceIntegrationTest.java
rename to persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/service/ParentServicePersistenceIntegrationTest.java
diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/spring/config/PersistenceTestConfig.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/config/PersistenceTestConfig.java
similarity index 96%
rename from persistence-modules/spring-hibernate4/src/test/java/com/baeldung/spring/config/PersistenceTestConfig.java
rename to persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/config/PersistenceTestConfig.java
index 9bf55c902a..34301741fe 100644
--- a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/spring/config/PersistenceTestConfig.java
+++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/config/PersistenceTestConfig.java
@@ -14,8 +14,8 @@ import org.springframework.core.env.Environment;
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
-import org.springframework.orm.hibernate4.HibernateTransactionManager;
-import org.springframework.orm.hibernate4.LocalSessionFactoryBean;
+import org.springframework.orm.hibernate5.HibernateTransactionManager;
+import org.springframework.orm.hibernate5.LocalSessionFactoryBean;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
@@ -45,7 +45,7 @@ import com.google.common.base.Preconditions;
@Configuration
@EnableTransactionManagement
-@EnableJpaRepositories(basePackages = { "com.baeldung.persistence" }, transactionManagerRef = "jpaTransactionManager")
+@EnableJpaRepositories(basePackages = { "com.baeldung.persistence" }, transactionManagerRef = "jpaTransactionManager", entityManagerFactoryRef = "jpaEntityManager")
@EnableJpaAuditing
@PropertySource({ "classpath:persistence-h2.properties" })
@ComponentScan({ "com.baeldung.persistence" })
@@ -68,7 +68,7 @@ public class PersistenceTestConfig {
return sessionFactory;
}
- @Bean
+ @Bean("jpaEntityManager")
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
final LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
emf.setDataSource(restDataSource());
diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepositoryIntegrationTest.java
index 38fd804195..b1158b3dae 100644
--- a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepositoryIntegrationTest.java
+++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepositoryIntegrationTest.java
@@ -6,6 +6,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.test.context.junit4.SpringRunner;
+import com.baeldung.spring.data.jpa.query.datetime.Article;
+import com.baeldung.spring.data.jpa.query.datetime.ArticleRepository;
+
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.List;
diff --git a/persistence-modules/spring-hibernate4/src/test/resources/fetching.cfg.xml b/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetching.cfg.xml
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/test/resources/fetching.cfg.xml
rename to persistence-modules/spring-data-jpa-query-2/src/test/resources/fetching.cfg.xml
diff --git a/persistence-modules/spring-hibernate4/src/test/resources/fetchingLazy.cfg.xml b/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetchingLazy.cfg.xml
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/test/resources/fetchingLazy.cfg.xml
rename to persistence-modules/spring-data-jpa-query-2/src/test/resources/fetchingLazy.cfg.xml
diff --git a/persistence-modules/spring-hibernate4/src/test/resources/persistence-h2.properties b/persistence-modules/spring-data-jpa-query-2/src/test/resources/persistence-h2.properties
similarity index 100%
rename from persistence-modules/spring-hibernate4/src/test/resources/persistence-h2.properties
rename to persistence-modules/spring-data-jpa-query-2/src/test/resources/persistence-h2.properties
diff --git a/persistence-modules/spring-hibernate-5/README.md b/persistence-modules/spring-hibernate-5/README.md
index 6d7526a13b..c7506026dd 100644
--- a/persistence-modules/spring-hibernate-5/README.md
+++ b/persistence-modules/spring-hibernate-5/README.md
@@ -12,4 +12,5 @@ This module contains articles about Hibernate 5 with Spring.
- [Hibernate Second-Level Cache](http://www.baeldung.com/hibernate-second-level-cache)
- [Deleting Objects with Hibernate](http://www.baeldung.com/delete-with-hibernate)
- [Spring, Hibernate and a JNDI Datasource](http://www.baeldung.com/spring-persistence-jpa-jndi-datasource)
-- [@Immutable in Hibernate](http://www.baeldung.com/hibernate-immutable)
\ No newline at end of file
+- [@Immutable in Hibernate](http://www.baeldung.com/hibernate-immutable)
+- [Guide to Hibernate 5 with Spring](https://www.baeldung.com/hibernate-4-spring)
\ No newline at end of file
diff --git a/persistence-modules/spring-hibernate4/.gitignore b/persistence-modules/spring-hibernate4/.gitignore
deleted file mode 100644
index d31cc4c619..0000000000
--- a/persistence-modules/spring-hibernate4/.gitignore
+++ /dev/null
@@ -1,15 +0,0 @@
-*.class
-
-#folders#
-/target
-/neoDb*
-/data
-/src/main/webapp/WEB-INF/classes
-*/META-INF/*
-
-# Packaged files #
-*.jar
-*.war
-*.ear
-/target/
-/target/
diff --git a/persistence-modules/spring-hibernate4/README.md b/persistence-modules/spring-hibernate4/README.md
deleted file mode 100644
index a5a72a9b7e..0000000000
--- a/persistence-modules/spring-hibernate4/README.md
+++ /dev/null
@@ -1,24 +0,0 @@
-## Spring with Hibernate 4
-
-This module contains articles about Spring with Hibernate 4
-
-### Relevant Articles:
-- [Guide to Hibernate 4 with Spring](https://www.baeldung.com/hibernate-4-spring)
-- [Hibernate Pagination](https://www.baeldung.com/hibernate-pagination)
-- [Sorting with Hibernate](https://www.baeldung.com/hibernate-sort)
-- [Stored Procedures with Hibernate](https://www.baeldung.com/stored-procedures-with-hibernate-tutorial)
-- [Hibernate: save, persist, update, merge, saveOrUpdate](https://www.baeldung.com/hibernate-save-persist-update-merge-saveorupdate)
-- [Eager/Lazy Loading In Hibernate](https://www.baeldung.com/hibernate-lazy-eager-loading)
-- [Auditing with JPA, Hibernate, and Spring Data JPA](https://www.baeldung.com/database-auditing-jpa)
-
-### Quick Start
-
-```
-git clone git://github.com/eugenp/REST.git
-cd REST
-mvn install
-mvn cargo:run
-```
-
-- **note**: starts on port `8082`
-
diff --git a/persistence-modules/spring-hibernate4/pom.xml b/persistence-modules/spring-hibernate4/pom.xml
deleted file mode 100644
index 3e5a6f913f..0000000000
--- a/persistence-modules/spring-hibernate4/pom.xml
+++ /dev/null
@@ -1,166 +0,0 @@
-
-
- 4.0.0
- spring-hibernate4
- 0.1-SNAPSHOT
- spring-hibernate4
-
-
- com.baeldung
- parent-spring-4
- 0.0.1-SNAPSHOT
- ../../parent-spring-4
-
-
-
-
-
-
- org.springframework
- spring-context
- ${org.springframework.version}
-
-
- commons-logging
- commons-logging
-
-
-
-
- org.springframework
- spring-aspects
- ${org.springframework.version}
-
-
- org.springframework.security
- spring-security-core
- ${org.springframework.security.version}
-
-
-
-
-
- org.springframework
- spring-orm
- ${org.springframework.version}
-
-
- org.springframework.data
- spring-data-jpa
- ${org.springframework.data.version}
-
-
- org.hibernate
- hibernate-core
- ${hibernate.version}
-
-
- org.hibernate
- hibernate-envers
- ${hibernate-envers.version}
-
-
- javax.transaction
- jta
- ${jta.version}
-
-
- mysql
- mysql-connector-java
- ${mysql-connector-java.version}
-
-
-
- org.apache.tomcat
- tomcat-dbcp
- ${tomcat-dbcp.version}
-
-
-
-
-
- org.hibernate
- hibernate-validator
- ${hibernate-validator.version}
-
-
- javax.el
- javax.el-api
- ${javax.el-api.version}
-
-
-
-
-
- com.google.guava
- guava
- ${guava.version}
-
-
-
-
-
- org.apache.commons
- commons-lang3
- ${commons-lang3.version}
- test
-
-
-
- org.springframework
- spring-test
- ${org.springframework.version}
- test
-
-
-
- org.springframework.security
- spring-security-test
- ${org.springframework.security.version}
- test
-
-
-
- org.hsqldb
- hsqldb
- ${hsqldb.version}
- test
-
-
- com.h2database
- h2
- ${h2.version}
- test
-
-
-
-
-
-
- 4.3.4.RELEASE
- 4.2.0.RELEASE
- 1.10.5.RELEASE
-
-
- 4.3.11.Final
- ${hibernate.version}
- 5.1.40
- 8.5.8
- 1.1
- 2.3.4
-
-
- 5.3.3.Final
- 2.2.5
-
-
- 19.0
-
-
- 2.22.2
- 5.6.2
- 4.13
-
-
-
diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/criteria/model/Item.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/criteria/model/Item.java
deleted file mode 100644
index 957207b7e6..0000000000
--- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/criteria/model/Item.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package com.baeldung.hibernate.criteria.model;
-
-import java.io.Serializable;
-
-public class Item implements Serializable {
-
- private static final long serialVersionUID = 1L;
- private Integer itemId;
- private String itemName;
- private String itemDescription;
- private Integer itemPrice;
-
- // constructors
- public Item() {
-
- }
-
- public Item(final Integer itemId, final String itemName, final String itemDescription) {
- super();
- this.itemId = itemId;
- this.itemName = itemName;
- this.itemDescription = itemDescription;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((itemId == null) ? 0 : itemId.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final Item other = (Item) obj;
- if (itemId == null) {
- if (other.itemId != null)
- return false;
- } else if (!itemId.equals(other.itemId))
- return false;
- return true;
- }
-
- public Integer getItemId() {
- return itemId;
- }
-
- public void setItemId(final Integer itemId) {
- this.itemId = itemId;
- }
-
- public String getItemName() {
- return itemName;
- }
-
- public void setItemName(final String itemName) {
- this.itemName = itemName;
- }
-
- public String getItemDescription() {
- return itemDescription;
- }
-
- public Integer getItemPrice() {
- return itemPrice;
- }
-
- public void setItemPrice(final Integer itemPrice) {
- this.itemPrice = itemPrice;
- }
-
- public void setItemDescription(final String itemDescription) {
- this.itemDescription = itemDescription;
- }
-}
diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/SpringContextTest.java b/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/SpringContextTest.java
deleted file mode 100644
index e19965773e..0000000000
--- a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/SpringContextTest.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.baeldung;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.support.AnnotationConfigContextLoader;
-
-import com.baeldung.spring.PersistenceConfig;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class)
-public class SpringContextTest {
-
- @Test
- public void whenSpringContextIsBootstrapped_thenNoExceptions() {
- }
-}
diff --git a/persistence-modules/spring-hibernate4/src/test/resources/.gitignore b/persistence-modules/spring-hibernate4/src/test/resources/.gitignore
deleted file mode 100644
index 83c05e60c8..0000000000
--- a/persistence-modules/spring-hibernate4/src/test/resources/.gitignore
+++ /dev/null
@@ -1,13 +0,0 @@
-*.class
-
-#folders#
-/target
-/neoDb*
-/data
-/src/main/webapp/WEB-INF/classes
-*/META-INF/*
-
-# Packaged files #
-*.jar
-*.war
-*.ear
\ No newline at end of file