diff --git a/gradle-5/.gitignore b/gradle-5/.gitignore
new file mode 100644
index 0000000000..7dd8895f4b
--- /dev/null
+++ b/gradle-5/.gitignore
@@ -0,0 +1,6 @@
+/build/
+/bin/
+.settings
+.gradle
+.project
+.classpath
\ No newline at end of file
diff --git a/gradle-5/build.gradle b/gradle-5/build.gradle
new file mode 100644
index 0000000000..a728845dff
--- /dev/null
+++ b/gradle-5/build.gradle
@@ -0,0 +1,54 @@
+plugins {
+ id "application"
+}
+apply plugin :"java"
+
+description = "Java MainClass execution examples"
+group = "com.baeldung"
+version = "0.0.1"
+sourceCompatibility = "1.8"
+targetCompatibility = "1.8"
+
+ext {
+ javaMainClass = "com.baeldung.gradle.exec.MainClass"
+}
+
+jar {
+ manifest {
+ attributes(
+ "Main-Class": javaMainClass
+ )
+ }
+}
+
+application {
+ mainClassName = javaMainClass
+}
+
+task runWithJavaExec(type: JavaExec) {
+ group = "Execution"
+ description = "Run the main class with JavaExecTask"
+ classpath = sourceSets.main.runtimeClasspath
+ main = javaMainClass
+}
+
+task runWithExec(type: Exec) {
+ dependsOn build
+ group = "Execution"
+ description = "Run the main class with ExecTask"
+ commandLine "java", "-classpath", sourceSets.main.runtimeClasspath.getAsPath(), javaMainClass
+}
+
+task runWithExecJarExecutable(type: Exec) {
+ dependsOn jar
+ group = "Execution"
+ description = "Run the output executable jar with ExecTask"
+ commandLine "java", "-jar", jar.archiveFile.get()
+}
+
+task runWithExecJarOnClassPath(type: Exec) {
+ dependsOn jar
+ group = "Execution"
+ description = "Run the mainClass from the output jar in classpath with ExecTask"
+ commandLine "java", "-classpath", jar.archiveFile.get() , javaMainClass
+}
\ No newline at end of file
diff --git a/gradle-5/gradle/wrapper/gradle-wrapper.jar b/gradle-5/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000000..736fb7d3f9
Binary files /dev/null and b/gradle-5/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle-5/gradle/wrapper/gradle-wrapper.properties b/gradle-5/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000000..b33419deee
--- /dev/null
+++ b/gradle-5/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip
diff --git a/gradle-5/gradlew b/gradle-5/gradlew
new file mode 100755
index 0000000000..27309d9231
--- /dev/null
+++ b/gradle-5/gradlew
@@ -0,0 +1,164 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/gradle-5/gradlew.bat b/gradle-5/gradlew.bat
new file mode 100644
index 0000000000..832fdb6079
--- /dev/null
+++ b/gradle-5/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/gradle-5/src/main/java/com/baeldung/gradle/exec/MainClass.java b/gradle-5/src/main/java/com/baeldung/gradle/exec/MainClass.java
new file mode 100644
index 0000000000..1e0c05389c
--- /dev/null
+++ b/gradle-5/src/main/java/com/baeldung/gradle/exec/MainClass.java
@@ -0,0 +1,8 @@
+package com.baeldung.gradle.exec;
+
+public class MainClass {
+
+ public static void main(String[] args) {
+ System.out.println("Goodbye cruel world ...");
+ }
+}
diff --git a/java-math/README.md b/java-math/README.md
index d821348204..244417d1a5 100644
--- a/java-math/README.md
+++ b/java-math/README.md
@@ -7,4 +7,5 @@
- [Find the Intersection of Two Lines in Java](https://www.baeldung.com/java-intersection-of-two-lines)
- [Round Up to the Nearest Hundred](https://www.baeldung.com/java-round-up-nearest-hundred)
- [Calculate Percentage in Java](https://www.baeldung.com/java-calculate-percentage)
-- [Convert Latitude and Longitude to a 2D Point in Java](https://www.baeldung.com/java-convert-latitude-longitude)
\ No newline at end of file
+- [Convert Latitude and Longitude to a 2D Point in Java](https://www.baeldung.com/java-convert-latitude-longitude)
+- [Debugging with Eclipse](https://www.baeldung.com/eclipse-debugging)
diff --git a/oauth2-framework-impl/README.md b/oauth2-framework-impl/README.md
new file mode 100644
index 0000000000..60fefe3415
--- /dev/null
+++ b/oauth2-framework-impl/README.md
@@ -0,0 +1,3 @@
+### Relevant Articles
+
+- [Implementing The OAuth 2.0 Authorization Framework Using Java EE](https://www.baeldung.com/java-ee-oauth2-implementation)
diff --git a/persistence-modules/spring-hibernate-5/README.md b/persistence-modules/spring-hibernate-5/README.md
index adfb152afd..7a18761a7b 100644
--- a/persistence-modules/spring-hibernate-5/README.md
+++ b/persistence-modules/spring-hibernate-5/README.md
@@ -5,3 +5,6 @@
- [JPA Criteria Queries](http://www.baeldung.com/hibernate-criteria-queries)
- [Introduction to Hibernate Search](http://www.baeldung.com/hibernate-search)
- [@DynamicUpdate with Spring Data JPA](https://www.baeldung.com/spring-data-jpa-dynamicupdate)
+- [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)
\ No newline at end of file
diff --git a/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6.fdt b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6.fdt
new file mode 100644
index 0000000000..c44ea80ed4
Binary files /dev/null and b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6.fdt differ
diff --git a/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6.fdx b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6.fdx
new file mode 100644
index 0000000000..77b3c43c21
Binary files /dev/null and b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6.fdx differ
diff --git a/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6.fnm b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6.fnm
new file mode 100644
index 0000000000..6a5f78d0a0
Binary files /dev/null and b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6.fnm differ
diff --git a/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6.nvd b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6.nvd
new file mode 100644
index 0000000000..7644ffa79b
Binary files /dev/null and b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6.nvd differ
diff --git a/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6.nvm b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6.nvm
new file mode 100644
index 0000000000..b2eb2c7a52
Binary files /dev/null and b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6.nvm differ
diff --git a/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6.si b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6.si
new file mode 100644
index 0000000000..67b02ea9fd
Binary files /dev/null and b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6.si differ
diff --git a/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6.tvd b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6.tvd
new file mode 100644
index 0000000000..b43b83f86a
Binary files /dev/null and b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6.tvd differ
diff --git a/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6.tvx b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6.tvx
new file mode 100644
index 0000000000..6b97c002b3
Binary files /dev/null and b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6.tvx differ
diff --git a/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6_Lucene50_0.doc b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6_Lucene50_0.doc
new file mode 100644
index 0000000000..f86ebad3d1
Binary files /dev/null and b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6_Lucene50_0.doc differ
diff --git a/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6_Lucene50_0.pos b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6_Lucene50_0.pos
new file mode 100644
index 0000000000..6299098895
Binary files /dev/null and b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6_Lucene50_0.pos differ
diff --git a/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6_Lucene50_0.tim b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6_Lucene50_0.tim
new file mode 100644
index 0000000000..3f8b1e4ab0
Binary files /dev/null and b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6_Lucene50_0.tim differ
diff --git a/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6_Lucene50_0.tip b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6_Lucene50_0.tip
new file mode 100644
index 0000000000..996b9bae87
Binary files /dev/null and b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_6_Lucene50_0.tip differ
diff --git a/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_7.cfe b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_7.cfe
new file mode 100644
index 0000000000..d1359e482e
Binary files /dev/null and b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_7.cfe differ
diff --git a/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_7.cfs b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_7.cfs
new file mode 100644
index 0000000000..476949c900
Binary files /dev/null and b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_7.cfs differ
diff --git a/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_7.si b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_7.si
new file mode 100644
index 0000000000..f85f471dbd
Binary files /dev/null and b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/_7.si differ
diff --git a/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/segments_9 b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/segments_9
new file mode 100644
index 0000000000..555f95a4ee
Binary files /dev/null and b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/segments_9 differ
diff --git a/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/write.lock b/persistence-modules/spring-hibernate-5/com.baeldung.hibernatesearch.model.Product/write.lock
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/persistence-modules/spring-hibernate-5/pom.xml b/persistence-modules/spring-hibernate-5/pom.xml
index e27775c76f..694ab570a5 100644
--- a/persistence-modules/spring-hibernate-5/pom.xml
+++ b/persistence-modules/spring-hibernate-5/pom.xml
@@ -51,6 +51,11 @@
hibernate-core
${hibernate.version}
+
+ org.hibernate
+ hibernate-ehcache
+ ${hibernate.version}
+
javax.transaction
jta
diff --git a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/cache/dao/AbstractJpaDAO.java b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/cache/dao/AbstractJpaDAO.java
new file mode 100644
index 0000000000..0d002b8fbb
--- /dev/null
+++ b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/cache/dao/AbstractJpaDAO.java
@@ -0,0 +1,46 @@
+package com.baeldung.hibernate.cache.dao;
+
+import java.io.Serializable;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+public abstract class AbstractJpaDAO {
+
+ private Class clazz;
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ public final void setClazz(final Class clazzToSet) {
+ this.clazz = clazzToSet;
+ }
+
+ public T findOne(final long id) {
+ return entityManager.find(clazz, id);
+ }
+
+ @SuppressWarnings("unchecked")
+ public List findAll() {
+ return entityManager.createQuery("from " + clazz.getName()).getResultList();
+ }
+
+ public void create(final T entity) {
+ entityManager.persist(entity);
+ }
+
+ public T update(final T entity) {
+ return entityManager.merge(entity);
+ }
+
+ public void delete(final T entity) {
+ entityManager.remove(entity);
+ }
+
+ public void deleteById(final long entityId) {
+ final T entity = findOne(entityId);
+ delete(entity);
+ }
+
+}
\ No newline at end of file
diff --git a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/cache/dao/FooDao.java b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/cache/dao/FooDao.java
new file mode 100644
index 0000000000..68c94fc0e3
--- /dev/null
+++ b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/cache/dao/FooDao.java
@@ -0,0 +1,17 @@
+package com.baeldung.hibernate.cache.dao;
+
+import com.baeldung.hibernate.cache.model.Foo;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class FooDao extends AbstractJpaDAO implements IFooDao {
+
+ public FooDao() {
+ super();
+
+ setClazz(Foo.class);
+ }
+
+ // API
+
+}
diff --git a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/cache/dao/IFooDao.java b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/cache/dao/IFooDao.java
new file mode 100644
index 0000000000..0a6d4bdbd6
--- /dev/null
+++ b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/cache/dao/IFooDao.java
@@ -0,0 +1,21 @@
+package com.baeldung.hibernate.cache.dao;
+
+import java.util.List;
+
+import com.baeldung.hibernate.cache.model.Foo;
+
+public interface IFooDao {
+
+ Foo findOne(long id);
+
+ List findAll();
+
+ void create(Foo entity);
+
+ Foo update(Foo entity);
+
+ void delete(Foo entity);
+
+ void deleteById(long entityId);
+
+}
diff --git a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/cache/model/Bar.java b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/cache/model/Bar.java
new file mode 100644
index 0000000000..cd8f3a57cc
--- /dev/null
+++ b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/cache/model/Bar.java
@@ -0,0 +1,102 @@
+package com.baeldung.hibernate.cache.model;
+
+import java.io.Serializable;
+import java.util.List;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.OrderBy;
+
+@Entity
+public class Bar implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private long id;
+
+ @Column(nullable = false)
+ private String name;
+
+ @OneToMany(mappedBy = "bar", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
+ @OrderBy("name ASC")
+ List fooList;
+
+ public Bar() {
+ super();
+ }
+
+ public Bar(final String name) {
+ super();
+
+ this.name = name;
+ }
+
+ // API
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(final long id) {
+
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ public List getFooList() {
+ return fooList;
+ }
+
+ public void setFooList(final List fooList) {
+ this.fooList = fooList;
+ }
+
+ //
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.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 Bar other = (Bar) obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder();
+ builder.append("Bar [name=").append(name).append("]");
+ return builder.toString();
+ }
+
+}
diff --git a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/cache/model/Foo.java b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/cache/model/Foo.java
new file mode 100644
index 0000000000..902d76e2cc
--- /dev/null
+++ b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/cache/model/Foo.java
@@ -0,0 +1,92 @@
+package com.baeldung.hibernate.cache.model;
+
+import org.hibernate.annotations.CacheConcurrencyStrategy;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+@Entity
+@Cacheable
+@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
+public class Foo implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public Foo() {
+ super();
+ }
+
+ public Foo(final String name) {
+ super();
+
+ this.name = name;
+ }
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name = "ID")
+ private Long id;
+ @Column(name = "NAME")
+ private String name;
+
+ @ManyToOne(targetEntity = Bar.class, fetch = FetchType.EAGER)
+ @JoinColumn(name = "BAR_ID")
+ private Bar bar;
+
+ public Bar getBar() {
+ return bar;
+ }
+
+ public void setBar(final Bar bar) {
+ this.bar = bar;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(final Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.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 Foo other = (Foo) obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder();
+ builder.append("Foo [name=").append(name).append("]");
+ return builder.toString();
+ }
+
+}
diff --git a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/cache/service/FooService.java b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/cache/service/FooService.java
new file mode 100644
index 0000000000..222968f98f
--- /dev/null
+++ b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/cache/service/FooService.java
@@ -0,0 +1,37 @@
+package com.baeldung.hibernate.cache.service;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.baeldung.hibernate.cache.dao.IFooDao;
+import com.baeldung.hibernate.cache.model.Foo;
+
+@Service
+@Transactional
+public class FooService {
+
+ @Autowired
+ private IFooDao dao;
+
+ public FooService() {
+ super();
+ }
+
+ // API
+
+ public void create(final Foo entity) {
+ dao.create(entity);
+ }
+
+ public Foo findOne(final long id) {
+ return dao.findOne(id);
+ }
+
+ public List findAll() {
+ return dao.findAll();
+ }
+
+}
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/config/PersistenceJNDIConfig.java b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/spring/PersistenceJNDIConfig.java
similarity index 92%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/config/PersistenceJNDIConfig.java
rename to persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/spring/PersistenceJNDIConfig.java
index 56ba68dcbb..5f12dc4f5e 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/config/PersistenceJNDIConfig.java
+++ b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/spring/PersistenceJNDIConfig.java
@@ -1,4 +1,4 @@
-package org.baeldung.config;
+package com.baeldung.spring;
import java.util.Properties;
@@ -24,8 +24,8 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
@EnableTransactionManagement
@PropertySource("classpath:persistence-jndi.properties")
-@ComponentScan("org.baeldung.persistence")
-@EnableJpaRepositories(basePackages = "org.baeldung.persistence.dao")
+@ComponentScan("com.baeldung.hibernate.cache")
+@EnableJpaRepositories(basePackages = "com.baeldung.hibernate.cache.dao")
public class PersistenceJNDIConfig {
@Autowired
@@ -35,7 +35,7 @@ public class PersistenceJNDIConfig {
public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws NamingException {
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource());
- em.setPackagesToScan("org.baeldung.persistence.model");
+ em.setPackagesToScan("com.baeldung.hibernate.cache.model");
em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
em.setJpaProperties(additionalProperties());
return em;
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfigL2Cache.java b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/spring/PersistenceJPAConfigL2Cache.java
similarity index 93%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfigL2Cache.java
rename to persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/spring/PersistenceJPAConfigL2Cache.java
index a236cf2331..93bcb30c5f 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfigL2Cache.java
+++ b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/spring/PersistenceJPAConfigL2Cache.java
@@ -1,4 +1,4 @@
-package org.baeldung.config;
+package com.baeldung.spring;
import com.google.common.base.Preconditions;
import org.springframework.beans.factory.annotation.Autowired;
@@ -23,8 +23,8 @@ import java.util.Properties;
@Configuration
@EnableTransactionManagement
@PropertySource({ "classpath:persistence-h2.properties" })
-@ComponentScan({ "org.baeldung.persistence" })
-@EnableJpaRepositories(basePackages = { "org.baeldung.persistence.dao", "org.baeldung.persistence.repository" })
+@ComponentScan({ "com.baeldung.hibernate.cache" })
+@EnableJpaRepositories(basePackages = { "com.baeldung.hibernate.cache.dao"})
public class PersistenceJPAConfigL2Cache {
@Autowired
@@ -50,7 +50,7 @@ public class PersistenceJPAConfigL2Cache {
}
protected String[] getPackagesToScan() {
- return new String[] { "org.baeldung.persistence.model" };
+ return new String[] { "com.baeldung.hibernate.cache.model" };
}
@Bean
diff --git a/persistence-modules/spring-hibernate-5/src/main/resources/persistence-h2.properties b/persistence-modules/spring-hibernate-5/src/main/resources/persistence-h2.properties
index 5a137e2310..e3544d354a 100644
--- a/persistence-modules/spring-hibernate-5/src/main/resources/persistence-h2.properties
+++ b/persistence-modules/spring-hibernate-5/src/main/resources/persistence-h2.properties
@@ -9,6 +9,9 @@ jdbc.pass=
hibernate.dialect=org.hibernate.dialect.H2Dialect
hibernate.show_sql=false
hibernate.hbm2ddl.auto=create-drop
+hibernate.cache.use_second_level_cache=true
+hibernate.cache.use_query_cache=true
+hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory
# hibernate.search.X
hibernate.search.default.directory_provider = filesystem
diff --git a/persistence-modules/spring-jpa/src/main/resources/persistence-jndi.properties b/persistence-modules/spring-hibernate-5/src/main/resources/persistence-jndi.properties
similarity index 100%
rename from persistence-modules/spring-jpa/src/main/resources/persistence-jndi.properties
rename to persistence-modules/spring-hibernate-5/src/main/resources/persistence-jndi.properties
diff --git a/persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/deletion/config/PersistenceJPAConfigDeletion.java b/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/persistence/deletion/config/PersistenceJPAConfigDeletion.java
similarity index 50%
rename from persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/deletion/config/PersistenceJPAConfigDeletion.java
rename to persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/persistence/deletion/config/PersistenceJPAConfigDeletion.java
index e5fb728a0a..3a2f227793 100644
--- a/persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/deletion/config/PersistenceJPAConfigDeletion.java
+++ b/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/persistence/deletion/config/PersistenceJPAConfigDeletion.java
@@ -1,6 +1,6 @@
-package org.baeldung.persistence.deletion.config;
+package com.baeldung.persistence.deletion.config;
-import org.baeldung.config.PersistenceJPAConfigL2Cache;
+import com.baeldung.spring.PersistenceJPAConfigL2Cache;
public class PersistenceJPAConfigDeletion extends PersistenceJPAConfigL2Cache {
@@ -10,6 +10,6 @@ public class PersistenceJPAConfigDeletion extends PersistenceJPAConfigL2Cache {
@Override
protected String[] getPackagesToScan() {
- return new String[] { "org.baeldung.persistence.deletion.model", "org.baeldung.persistence.model" };
+ return new String[] { "com.baeldung.persistence.deletion.model", "com.baeldung.persistence.model" };
}
}
\ No newline at end of file
diff --git a/persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/deletion/model/Bar.java b/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/persistence/deletion/model/Bar.java
similarity index 95%
rename from persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/deletion/model/Bar.java
rename to persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/persistence/deletion/model/Bar.java
index 26c4846fd2..85efd573ca 100644
--- a/persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/deletion/model/Bar.java
+++ b/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/persistence/deletion/model/Bar.java
@@ -1,4 +1,4 @@
-package org.baeldung.persistence.deletion.model;
+package com.baeldung.persistence.deletion.model;
import javax.persistence.*;
import java.util.ArrayList;
diff --git a/persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/deletion/model/Baz.java b/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/persistence/deletion/model/Baz.java
similarity index 94%
rename from persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/deletion/model/Baz.java
rename to persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/persistence/deletion/model/Baz.java
index 4fb3f8965e..bea97154d4 100644
--- a/persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/deletion/model/Baz.java
+++ b/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/persistence/deletion/model/Baz.java
@@ -1,4 +1,4 @@
-package org.baeldung.persistence.deletion.model;
+package com.baeldung.persistence.deletion.model;
import javax.persistence.*;
diff --git a/persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/deletion/model/Foo.java b/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/persistence/deletion/model/Foo.java
similarity index 95%
rename from persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/deletion/model/Foo.java
rename to persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/persistence/deletion/model/Foo.java
index 00fc34c166..f0d57c5b6e 100644
--- a/persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/deletion/model/Foo.java
+++ b/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/persistence/deletion/model/Foo.java
@@ -1,4 +1,4 @@
-package org.baeldung.persistence.deletion.model;
+package com.baeldung.persistence.deletion.model;
import org.hibernate.annotations.Where;
diff --git a/persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/service/DeletionIntegrationTest.java b/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/persistence/service/DeletionIntegrationTest.java
similarity index 94%
rename from persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/service/DeletionIntegrationTest.java
rename to persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/persistence/service/DeletionIntegrationTest.java
index 0dbb7dbfe8..dfc944f649 100644
--- a/persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/service/DeletionIntegrationTest.java
+++ b/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/persistence/service/DeletionIntegrationTest.java
@@ -1,9 +1,5 @@
-package org.baeldung.persistence.service;
+package com.baeldung.persistence.service;
-import org.baeldung.persistence.deletion.config.PersistenceJPAConfigDeletion;
-import org.baeldung.persistence.deletion.model.Bar;
-import org.baeldung.persistence.deletion.model.Baz;
-import org.baeldung.persistence.deletion.model.Foo;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -15,6 +11,11 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.Transactional;
+import com.baeldung.persistence.deletion.config.PersistenceJPAConfigDeletion;
+import com.baeldung.persistence.deletion.model.Bar;
+import com.baeldung.persistence.deletion.model.Baz;
+import com.baeldung.persistence.deletion.model.Foo;
+
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
diff --git a/persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/service/SecondLevelCacheIntegrationTest.java b/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/persistence/service/SecondLevelCacheIntegrationTest.java
similarity index 89%
rename from persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/service/SecondLevelCacheIntegrationTest.java
rename to persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/persistence/service/SecondLevelCacheIntegrationTest.java
index 4de8d321d5..e3436d762e 100644
--- a/persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/service/SecondLevelCacheIntegrationTest.java
+++ b/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/persistence/service/SecondLevelCacheIntegrationTest.java
@@ -1,9 +1,13 @@
-package org.baeldung.persistence.service;
+package com.baeldung.persistence.service;
+
+import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.junit.Assert.assertThat;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
-import net.sf.ehcache.CacheManager;
-import org.baeldung.config.PersistenceJPAConfigL2Cache;
-import org.baeldung.persistence.model.Bar;
-import org.baeldung.persistence.model.Foo;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -15,13 +19,12 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.support.TransactionTemplate;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import javax.persistence.Query;
+import com.baeldung.hibernate.cache.model.Bar;
+import com.baeldung.hibernate.cache.model.Foo;
+import com.baeldung.hibernate.cache.service.FooService;
+import com.baeldung.spring.PersistenceJPAConfigL2Cache;
-import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
-import static org.hamcrest.Matchers.greaterThan;
-import static org.junit.Assert.assertThat;
+import net.sf.ehcache.CacheManager;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { PersistenceJPAConfigL2Cache.class }, loader = AnnotationConfigContextLoader.class)
@@ -45,7 +48,7 @@ public class SecondLevelCacheIntegrationTest {
final Foo foo = new Foo(randomAlphabetic(6));
fooService.create(foo);
fooService.findOne(foo.getId());
- final int size = CacheManager.ALL_CACHE_MANAGERS.get(0).getCache("org.baeldung.persistence.model.Foo").getSize();
+ final int size = CacheManager.ALL_CACHE_MANAGERS.get(0).getCache("com.baeldung.hibernate.cache.model.Foo").getSize();
assertThat(size, greaterThan(0));
}
@@ -65,7 +68,7 @@ public class SecondLevelCacheIntegrationTest {
return nativeQuery.executeUpdate();
});
- final int size = CacheManager.ALL_CACHE_MANAGERS.get(0).getCache("org.baeldung.persistence.model.Foo").getSize();
+ final int size = CacheManager.ALL_CACHE_MANAGERS.get(0).getCache("com.baeldung.hibernate.cache.model.Foo").getSize();
assertThat(size, greaterThan(0));
}
diff --git a/persistence-modules/spring-jpa/README.md b/persistence-modules/spring-jpa/README.md
index e856e4808e..56ce68c126 100644
--- a/persistence-modules/spring-jpa/README.md
+++ b/persistence-modules/spring-jpa/README.md
@@ -7,9 +7,6 @@
- [The DAO with JPA and Spring](http://www.baeldung.com/spring-dao-jpa)
- [JPA Pagination](http://www.baeldung.com/jpa-pagination)
- [Sorting with JPA](http://www.baeldung.com/jpa-sort)
-- [Hibernate Second-Level Cache](http://www.baeldung.com/hibernate-second-level-cache)
-- [Spring, Hibernate and a JNDI Datasource](http://www.baeldung.com/spring-persistence-jpa-jndi-datasource)
-- [Deleting Objects with Hibernate](http://www.baeldung.com/delete-with-hibernate)
- [Self-Contained Testing Using an In-Memory Database](http://www.baeldung.com/spring-jpa-test-in-memory-database)
- [A Guide to Spring AbstractRoutingDatasource](http://www.baeldung.com/spring-abstract-routing-data-source)
- [A Guide to Hibernate with Spring 4](http://www.baeldung.com/the-persistence-layer-with-spring-and-jpa)
diff --git a/persistence-modules/spring-jpa/pom.xml b/persistence-modules/spring-jpa/pom.xml
index 0961cabaff..792f3918b6 100644
--- a/persistence-modules/spring-jpa/pom.xml
+++ b/persistence-modules/spring-jpa/pom.xml
@@ -44,11 +44,6 @@
hibernate-entitymanager
${hibernate.version}
-
- org.hibernate
- hibernate-ehcache
- ${hibernate.version}
-
xml-apis
xml-apis
diff --git a/persistence-modules/spring-jpa/src/main/resources/persistence-h2.properties b/persistence-modules/spring-jpa/src/main/resources/persistence-h2.properties
index 716a96fde3..a3060cc796 100644
--- a/persistence-modules/spring-jpa/src/main/resources/persistence-h2.properties
+++ b/persistence-modules/spring-jpa/src/main/resources/persistence-h2.properties
@@ -7,7 +7,4 @@ jdbc.pass=
# hibernate.X
hibernate.dialect=org.hibernate.dialect.H2Dialect
hibernate.show_sql=true
-hibernate.hbm2ddl.auto=create-drop
-hibernate.cache.use_second_level_cache=true
-hibernate.cache.use_query_cache=true
-hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory
\ No newline at end of file
+hibernate.hbm2ddl.auto=create-drop
\ No newline at end of file
diff --git a/persistence-modules/spring-jpa/src/test/java/com/baeldung/SpringContextIntegrationTest.java b/persistence-modules/spring-jpa/src/test/java/com/baeldung/SpringContextIntegrationTest.java
index 822cbb8ed5..9b0cdf180f 100644
--- a/persistence-modules/spring-jpa/src/test/java/com/baeldung/SpringContextIntegrationTest.java
+++ b/persistence-modules/spring-jpa/src/test/java/com/baeldung/SpringContextIntegrationTest.java
@@ -1,6 +1,6 @@
package com.baeldung;
-import org.baeldung.config.PersistenceJPAConfigL2Cache;
+import org.baeldung.config.PersistenceJPAConfig;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.annotation.DirtiesContext;
@@ -10,7 +10,7 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader;
import org.springframework.test.context.web.WebAppConfiguration;
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = { PersistenceJPAConfigL2Cache.class }, loader = AnnotationConfigContextLoader.class)
+@ContextConfiguration(classes = { PersistenceJPAConfig.class }, loader = AnnotationConfigContextLoader.class)
@WebAppConfiguration
@DirtiesContext
public class SpringContextIntegrationTest {
diff --git a/persistence-modules/spring-jpa/src/test/java/com/baeldung/SpringContextTest.java b/persistence-modules/spring-jpa/src/test/java/com/baeldung/SpringContextTest.java
index 291e49d0c4..de333eef91 100644
--- a/persistence-modules/spring-jpa/src/test/java/com/baeldung/SpringContextTest.java
+++ b/persistence-modules/spring-jpa/src/test/java/com/baeldung/SpringContextTest.java
@@ -1,6 +1,6 @@
package com.baeldung;
-import org.baeldung.config.PersistenceJPAConfigL2Cache;
+import org.baeldung.config.PersistenceJPAConfig;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.annotation.DirtiesContext;
@@ -10,7 +10,7 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader;
import org.springframework.test.context.web.WebAppConfiguration;
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = { PersistenceJPAConfigL2Cache.class }, loader = AnnotationConfigContextLoader.class)
+@ContextConfiguration(classes = { PersistenceJPAConfig.class }, loader = AnnotationConfigContextLoader.class)
@WebAppConfiguration
@DirtiesContext
public class SpringContextTest {
diff --git a/persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/service/FooPaginationPersistenceIntegrationTest.java b/persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/service/FooPaginationPersistenceIntegrationTest.java
index bf49a431e1..76c34affb9 100644
--- a/persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/service/FooPaginationPersistenceIntegrationTest.java
+++ b/persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/service/FooPaginationPersistenceIntegrationTest.java
@@ -16,7 +16,6 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import org.baeldung.config.PersistenceJPAConfig;
-import org.baeldung.config.PersistenceJPAConfigL2Cache;
import org.baeldung.persistence.model.Foo;
import org.junit.Before;
import org.junit.Test;
@@ -28,7 +27,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = { PersistenceJPAConfigL2Cache.class }, loader = AnnotationConfigContextLoader.class)
+@ContextConfiguration(classes = { PersistenceJPAConfig.class }, loader = AnnotationConfigContextLoader.class)
@DirtiesContext
public class FooPaginationPersistenceIntegrationTest {
diff --git a/persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java b/persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java
index 45316cf06c..e1b53c8ded 100644
--- a/persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java
+++ b/persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java
@@ -3,7 +3,6 @@ package org.baeldung.persistence.service;
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
import org.baeldung.config.PersistenceJPAConfig;
-import org.baeldung.config.PersistenceJPAConfigL2Cache;
import org.baeldung.persistence.model.Foo;
import org.junit.Assert;
import org.junit.Test;
@@ -18,7 +17,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = { PersistenceJPAConfigL2Cache.class }, loader = AnnotationConfigContextLoader.class)
+@ContextConfiguration(classes = { PersistenceJPAConfig.class }, loader = AnnotationConfigContextLoader.class)
@DirtiesContext
public class FooServicePersistenceIntegrationTest {
diff --git a/persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingIntegrationTest.java b/persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingIntegrationTest.java
index 61a3bfd565..40249b4b30 100644
--- a/persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingIntegrationTest.java
+++ b/persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingIntegrationTest.java
@@ -10,7 +10,7 @@ import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
-import org.baeldung.config.PersistenceJPAConfigL2Cache;
+import org.baeldung.config.PersistenceJPAConfig;
import org.baeldung.persistence.model.Bar;
import org.baeldung.persistence.model.Foo;
import org.junit.Test;
@@ -21,7 +21,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = { PersistenceJPAConfigL2Cache.class }, loader = AnnotationConfigContextLoader.class)
+@ContextConfiguration(classes = { PersistenceJPAConfig.class }, loader = AnnotationConfigContextLoader.class)
@DirtiesContext
@SuppressWarnings("unchecked")
public class FooServiceSortingIntegrationTest {
diff --git a/persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingWitNullsManualIntegrationTest.java b/persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingWitNullsManualIntegrationTest.java
index 50fdf5f0f3..c530003ac1 100644
--- a/persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingWitNullsManualIntegrationTest.java
+++ b/persistence-modules/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingWitNullsManualIntegrationTest.java
@@ -10,7 +10,6 @@ import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import org.baeldung.config.PersistenceJPAConfig;
-import org.baeldung.config.PersistenceJPAConfigL2Cache;
import org.baeldung.persistence.model.Foo;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -21,7 +20,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = { PersistenceJPAConfigL2Cache.class }, loader = AnnotationConfigContextLoader.class)
+@ContextConfiguration(classes = { PersistenceJPAConfig.class }, loader = AnnotationConfigContextLoader.class)
@DirtiesContext
public class FooServiceSortingWitNullsManualIntegrationTest {
diff --git a/testing-modules/junit-4/README.md b/testing-modules/junit-4/README.md
new file mode 100644
index 0000000000..4d4588912b
--- /dev/null
+++ b/testing-modules/junit-4/README.md
@@ -0,0 +1,3 @@
+### Relevant Articles
+
+- [Guide to JUnit 4 Rules](https://www.baeldung.com/junit-4-rules)