JEHibernate 3.0
Modern Hibernate/JPA Utility Library for Minecraft Plugins
What is JEHibernate?
JEHibernate eliminates 65%+ of database boilerplate code in your Spigot/Paper plugins. It wraps Hibernate ORM with a clean, fluent API designed specifically for the Minecraft plugin lifecycle — async operations that don't block the main thread, cached repositories for fast player lookups, and session-scoped lazy loading that actually works.
Works with: Spigot, Paper, Folia, and Java Spring applications.
Supports: Java 17, 21, and 24 (virtual threads automatically enabled on 21+).
Key Features
- Zero-Configuration Scanning — Auto-discovers your entities and repositories. No XML, no persistence.xml.
- Session-Scoped Lazy Loading — withSession() keeps the EntityManager open so lazy collections actually work.
- Fluent Query Builder — Type-safe queries with AND/OR conditions, multi-sort, fetch joins, pagination, and streaming.
- Dual-Layer Caching — Caffeine-backed cache by ID and by custom key with configurable expiration strategies.
- Async Virtual Threads — Every operation has an async variant. Virtual threads on Java 21+, thread pool fallback on 17.
- Optimistic Lock Retry — Automatic retry with exponential backoff for concurrent modifications and deadlocks.
- 8 Database Support — H2, MySQL, MariaDB, PostgreSQL, Oracle, SQL Server, SQLite, HSQLDB.
- Connection Pooling — Built-in Agroal support for production deployments.
- Slow Query Detection — Automatic WARN logging for queries exceeding 500ms.
- Properties File Config — Server admins switch databases by editing one file. No recompilation
1. Define an Entity
Code (Java):
Code (Java):
public class PlayerRepository extends AbstractCachedRepository <PlayerData, UUID, UUID > {
public PlayerRepository (ExecutorService ex, EntityManagerFactory emf, Class <PlayerData > cls ) {
super (ex, emf, cls, PlayerData ::getId,
CacheConfig. builder ( )
. expiration (Duration. ofMinutes ( 30 ) )
. maxSize ( 5000 )
. expireAfterAccess ( true )
. build ( ) ) ;
}
}
Code (Java):
public class MyPlugin extends JavaPlugin {
private JEHibernate jeHibernate ;
@Override
public void onEnable ( ) {
saveResource ( "database/hibernate.properties", false ) ;
jeHibernate = JEHibernate. builder ( )
. configuration (config -> config. fromProperties (
PropertyLoader. load (getDataFolder ( ), "database", "hibernate.properties" ) ) )
. scanPackages ( "com.example.myplugin" )
. build ( ) ;
var playerRepo = jeHibernate. repositories ( ). get (PlayerRepository. class ) ;
playerRepo. preloadAsync ( ) ; // non-blocking cache warmup
}
@Override
public void onDisable ( ) {
jeHibernate. close ( ) ;
}
}
- 80% less code — repo.findByIdOrThrow(id) vs manual connection/statement/resultset handling
- No SQL injection risk — All queries use parameterized Criteria API
- Automatic schema management — Tables created/updated from your entity classes
- Thread-safe by design — Each operation gets its own EntityManager
- Database-agnostic — Switch from H2 to MySQL by changing one config line
- Built-in caching — No need to manage your own ConcurrentHashMaps
Supported Databases
| Database | Config Prefix | Driver (auto-detected) |
| H2 | h2 | org.h2.Driver |
| MySQL | mysql | com.mysql.cj.jdbc.Driver |
| MariaDB | mariadb | org.mariadb.jdbc.Driver |
| PostgreSQL | postgresql | org.postgresql.Driver |
| SQLite | sqlite | org.sqlite.JDBC |
| Oracle | oracle | oracle.jdbc.OracleDriver |
| SQL Server | mssql | com.microsoft.sqlserver.jdbc.SQLServerDriver |
| HSQLDB | hsqldb | org.hsqldb.jdbc.JDBCDriver |
Entity Base Classes
All base classes provide automatic createdAt/ updatedAt timestamps, optimistic locking via [USER=24464]@version[/USER], and correct equals/ hashCode.
- LongIdEntity — Auto-increment Long ID (most common)
- UuidEntity — Auto-generated UUID stored as BINARY(16) (ideal for players)
- StringIdEntity — Custom String ID for natural keys
Dependency (Gradle)
Code (Text):
dependencies {
implementation("de.jexcellence.hibernate:JEHibernate:3.0.0")
runtimeOnly("com.h2database:h2:2.4.240") // or your database driver
}
Code (XML):
<dependency>
<groupId>de.jexcellence.hibernate </groupId>
<artifactId>JEHibernate </artifactId>
<version>3.0.0 </version>
</dependency>
Quick facts
- Edition: Minecraft Java
- File type: .jar
- Minecraft versions listed: 1.17, 1.18, 1.19
- How to install: Install the matching mod loader (Forge, Fabric or NeoForge) for your Minecraft version. → Download the .jar. → Put it in the .minecraft/mods folder and launch that loader profile.
- Where to get it: Opens on Spigot — not every file is mirrored on our own servers.
Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.
JEHibernate is a free Minecraft Java mod. Compatible with Minecraft 1.17, 1.18, 1.19, 1.20 and newer. Downloaded 31 times (via Spigot). Download it and open it directly in the game.