The High-Performance Java Persistence book and video course code examples
Java
1,503
1,469 commits
updated Oct 15, 2026
The High-Performance Java Persistence book and video course code examples. I wrote this article about this repository since it's one of the best way to test JDBC, JPA, Hibernate or even jOOQ code. Or, if you prefer videos, you can watch this presentation on YouTube.
Imagine having a tool that can automatically detect if you are using JPA and Hibernate properly. No more performance issues, no more having to spend countless hours trying to figure out why your application is barely crawling.
Imagine discovering early during the development cycle that you are using suboptimal mappings and entity relationships or that you are missing performance-related settings.
More, with Hypersistence Optimizer, you can detect all such issues during testing and make sure you don't deploy to production a change that will affect data access layer performance.
Hypersistence Optimizer is the tool you've been long waiting for!
If you are interested in on-site training, I can offer you my High-Performance Java Persistence training which can be adapted to one, two or three days of sessions. For more details, check out my website.
If you want me to review your application and provide insight into how you can optimize it to run faster, then check out my consulting page.
If you want the fastest way to learn how to speed up a Java database application, then you should definitely enroll in my High-Performance Java Persistence video courses.
Or, if you prefer reading books, you are going to love my High-Performance Java Persistence book as well.
All examples require at least Java 17 because of the awesome Text Blocks feature, which makes JPQL and SQL queries so much readable.
You need to use Maven 3.6.2 or newer to build the project.
On IntelliJ IDEA, the project runs just fine. You will have to make sure to select Java 17 or newer.
The project uses various database systems for integration testing, and you can configure the JDBC connection settings using the
DatasourceProvider instances (e.g., PostgreSQLDataSourceProvider).
By default, without configuring any database explicitly, HSQLDB is used for testing.
However, since some integration tests are designed to work on specific relational databases, we will need to have those databases started prior to running those tests.
Therefore, when running a DB-specific test, this GitHub repository will execute the following steps:
While you don't need to install any database manually on your local OS, this is recommended since your tests will run much faster than if they used Testcontainers.
PostgreSQL
You can install PostgreSQL, and the password for the postgres user should be admin.
Now you need to create a high_performance_java_persistence database.
Oracle
You need to download and install Oracle XE
Set the sys password to admin
Connect to Oracle using the "sys as sysdba" user and create a new user:
alter session set "_ORACLE_SCRIPT"=true;
create user oracle identified by admin default tablespace users;
grant dba to oracle;
alter system set processes=1000 scope=spfile;
alter system set sessions=1000 scope=spfile;
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
Open the C:\app\${user.name}\product\21c\homes\OraDB21Home1\network\admin folder where ${user.name} is your current Windows username.
Locate the tnsnames.ora and listener.ora files and change the port from 1522 to 1521 if that's the case. If you made these modifications,
you need to restart the OracleOraDB21Home1TNSListener and OracleServiceXE Windows services.
MySQL
You should install MySQL 8, and the password for the mysql user should be admin.
Now, you need to create a high_performance_java_persistence schema
Besides having all privileges on this schema, the mysql user also requires select permission on mysql.PROC.
If you don't have a mysql user created at database installation time, you can create one as follows:
CREATE USER 'mysql'@'localhost';
SET PASSWORD for 'mysql'@'localhost'='admin';
GRANT ALL PRIVILEGES ON high_performance_java_persistence.* TO 'mysql'@'localhost';
GRANT SELECT ON mysql.* TO 'mysql'@'localhost';
FLUSH PRIVILEGES;
SQL Server
You can install SQL Server Express Edition with Tools. Choose mixed mode authentication and set the sa user password to adm1n.
Open SQL Server Configuration Manager -> SQL Server Network Configuration and enable Named Pipes and TCP
In the right pane of the TCP/IP option, choose Properties, then IP Addresses and make sure you Enable all listed IP addresses. You need to blank the dynamic TCP port value and configure the static TCP port 1433 for all IPs.
Open SQL Server Management Studio and create the high_performance_java_persistence database
The build.bat and build.sh scripts start Docker containers for MySQL and PostgreSQL automatically.
This is useful for first-time project setup when local database servers are not installed.
If you want to start or stop them manually, use:
docker compose up -d mysql postgres
docker compose down
Before building the project, make sure Docker is installed and running. The build scripts will start MySQL and PostgreSQL containers automatically.
If the database servers are not available, and the Docker service is not running, the build will fail with the following error message:
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server
To build the project, don't use install or package. Instead, just run the build script:
build
Afterward, just pick one test from the IDE and run it individually.
Don't you run all tests at once (e.g.
mvn clean test) because the test suite will take a very long time to complete.So, run the test you are interested in individually.
Enjoy learning more about Java Persistence, Hibernate, and database systems!
556 followers · starred Dec 2016
153 followers · starred Jan 2024
39 followers · starred Apr 2017
161 followers · starred Apr 2025
The High-Performance Java Persistence book and video course code examples
Java
1,503
1,469 commits
updated Oct 15, 2026
The High-Performance Java Persistence book and video course code examples. I wrote this article about this repository since it's one of the best way to test JDBC, JPA, Hibernate or even jOOQ code. Or, if you prefer videos, you can watch this presentation on YouTube.
Imagine having a tool that can automatically detect if you are using JPA and Hibernate properly. No more performance issues, no more having to spend countless hours trying to figure out why your application is barely crawling.
Imagine discovering early during the development cycle that you are using suboptimal mappings and entity relationships or that you are missing performance-related settings.
More, with Hypersistence Optimizer, you can detect all such issues during testing and make sure you don't deploy to production a change that will affect data access layer performance.
Hypersistence Optimizer is the tool you've been long waiting for!
If you are interested in on-site training, I can offer you my High-Performance Java Persistence training which can be adapted to one, two or three days of sessions. For more details, check out my website.
If you want me to review your application and provide insight into how you can optimize it to run faster, then check out my consulting page.
If you want the fastest way to learn how to speed up a Java database application, then you should definitely enroll in my High-Performance Java Persistence video courses.
Or, if you prefer reading books, you are going to love my High-Performance Java Persistence book as well.
All examples require at least Java 17 because of the awesome Text Blocks feature, which makes JPQL and SQL queries so much readable.
You need to use Maven 3.6.2 or newer to build the project.
On IntelliJ IDEA, the project runs just fine. You will have to make sure to select Java 17 or newer.
The project uses various database systems for integration testing, and you can configure the JDBC connection settings using the
DatasourceProvider instances (e.g., PostgreSQLDataSourceProvider).
By default, without configuring any database explicitly, HSQLDB is used for testing.
However, since some integration tests are designed to work on specific relational databases, we will need to have those databases started prior to running those tests.
Therefore, when running a DB-specific test, this GitHub repository will execute the following steps:
While you don't need to install any database manually on your local OS, this is recommended since your tests will run much faster than if they used Testcontainers.
PostgreSQL
You can install PostgreSQL, and the password for the postgres user should be admin.
Now you need to create a high_performance_java_persistence database.
Oracle
You need to download and install Oracle XE
Set the sys password to admin
Connect to Oracle using the "sys as sysdba" user and create a new user:
alter session set "_ORACLE_SCRIPT"=true;
create user oracle identified by admin default tablespace users;
grant dba to oracle;
alter system set processes=1000 scope=spfile;
alter system set sessions=1000 scope=spfile;
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
Open the C:\app\${user.name}\product\21c\homes\OraDB21Home1\network\admin folder where ${user.name} is your current Windows username.
Locate the tnsnames.ora and listener.ora files and change the port from 1522 to 1521 if that's the case. If you made these modifications,
you need to restart the OracleOraDB21Home1TNSListener and OracleServiceXE Windows services.
MySQL
You should install MySQL 8, and the password for the mysql user should be admin.
Now, you need to create a high_performance_java_persistence schema
Besides having all privileges on this schema, the mysql user also requires select permission on mysql.PROC.
If you don't have a mysql user created at database installation time, you can create one as follows:
CREATE USER 'mysql'@'localhost';
SET PASSWORD for 'mysql'@'localhost'='admin';
GRANT ALL PRIVILEGES ON high_performance_java_persistence.* TO 'mysql'@'localhost';
GRANT SELECT ON mysql.* TO 'mysql'@'localhost';
FLUSH PRIVILEGES;
SQL Server
You can install SQL Server Express Edition with Tools. Choose mixed mode authentication and set the sa user password to adm1n.
Open SQL Server Configuration Manager -> SQL Server Network Configuration and enable Named Pipes and TCP
In the right pane of the TCP/IP option, choose Properties, then IP Addresses and make sure you Enable all listed IP addresses. You need to blank the dynamic TCP port value and configure the static TCP port 1433 for all IPs.
Open SQL Server Management Studio and create the high_performance_java_persistence database
The build.bat and build.sh scripts start Docker containers for MySQL and PostgreSQL automatically.
This is useful for first-time project setup when local database servers are not installed.
If you want to start or stop them manually, use:
docker compose up -d mysql postgres
docker compose down
Before building the project, make sure Docker is installed and running. The build scripts will start MySQL and PostgreSQL containers automatically.
If the database servers are not available, and the Docker service is not running, the build will fail with the following error message:
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server
To build the project, don't use install or package. Instead, just run the build script:
build
Afterward, just pick one test from the IDE and run it individually.
Don't you run all tests at once (e.g.
mvn clean test) because the test suite will take a very long time to complete.So, run the test you are interested in individually.
Enjoy learning more about Java Persistence, Hibernate, and database systems!
556 followers · starred Dec 2016
153 followers · starred Jan 2024
39 followers · starred Apr 2017
161 followers · starred Apr 2025