Introduction
Changelog
Contact
Guides
Getting Started
Entities
Repositories
Queries & Specifications
Configuration & Pooling
Migrations
Spring Boot
Spigot & Paper Plugins
Recipes
Reference
Databases
Troubleshooting
Advanced
Multi-tenancy
Audit Trail
Testing
TrademarkTrademark
Ctrl k
Search…
Get started
Introduction
Changelog
Contact
Guides
Getting Started
Entities
Repositories
Queries & Specifications
Configuration & Pooling
Migrations
Spring Boot
Spigot & Paper Plugins
Recipes
Reference
Databases
Troubleshooting
Advanced
Multi-tenancy
Audit Trail
Testing
TrademarkTrademark© Aveiro. All rights reserved.
Built with Aveiro
Guide

Configuration & Pooling

Configure JEHibernate with the builder or a properties file, tune the HikariCP connection pool, and read pool health at runtime.
Updated last month
Queries & Specifications
Migrations
JEHibernate is configured either programmatically with a builder or from a properties file an admin can edit without recompiling. HikariCP is the connection pool, owned and bounded by JEHibernate.

Builder API

var jeHibernate = JEHibernate.builder()
    .configuration(config -> config
        .database(DatabaseType.POSTGRESQL)
        .url("jdbc:postgresql://localhost:5432/app")
        .credentials("app", "secret")
        .ddlAuto("validate")
        .batchSize(50)
        .showSql(false)
        .formatSql(false)
        .connectionPool(5, 20))      // minIdle, maxSize
    .scanPackages("com.example.domain")
    .build();
Other builder methods: property(key, value) for any raw hibernate.* setting, namingStrategy(...), pool(PoolConfig) for full pool control, dataSource(DataSource) to reuse an external pool, migration(MigrationConfig), multiTenancy(...), enableAudit(), and enableSecondLevelCache().

Properties file

Load from the classpath, filesystem, or a plugin data folder. Admins switch databases by editing one file.
The property prefix is the database type: {prefix}.url, {prefix}.username, {prefix}.password, and optional {prefix}.driver / {prefix}.dialect to override the auto-detected defaults.

The connection pool

HikariCP is the default. JEHibernate owns the DataSource and hands it to Hibernate, so the pool is real and bounded — no silent "internal pool exhausted" behaviour under load. Tune it with a PoolConfig:
The legacy connectionPool(minIdle, maxSize) still works and maps onto PoolConfig.

Reading pool health

Surface these on an admin command or a metrics endpoint to see saturation before it bites.

Reusing an existing DataSource

In Spring, or anywhere a pool already exists, hand it to JEHibernate instead of creating a second one. JEHibernate will not close a pool it does not own.
ddl-auto defaults to validate
Since 4.0, schema is owned by migrations. If you want Hibernate to manage DDL instead, set ddlAuto("update") explicitly or disable migrations. See Migrations.
var jeh = JEHibernate.fromProperties("hibernate.properties");                       // classpath/filesystem
var jeh = JEHibernate.fromProperties(getDataFolder(), "database", "hibernate.properties"); // plugin
database.type=POSTGRESQL
postgresql.url=jdbc:postgresql://localhost:5432/app
postgresql.username=app
postgresql.password=secret
# Any hibernate.* key passes straight through:
hibernate.hbm2ddl.auto=validate
hibernate.show_sql=false
# Pool tuning via jehibernate.pool.*:
jehibernate.pool.maximumPoolSize=10
jehibernate.pool.minimumIdle=2
config.pool(new PoolConfig(
    20,       // maximumPoolSize
    5,        // minimumIdle
    30_000,   // idleTimeout (ms)
    10_000,   // connectionTimeout (ms)
    1_800_000,// maxLifetime (ms)
    0,        // leakDetectionThreshold (ms; 0 = off)
    5_000     // validationTimeout (ms)
));
PoolHealth h = jeHibernate.getPoolHealth();
// h.active(), h.idle(), h.total(), h.threadsAwaiting(), h.available()

DataSource ds = jeHibernate.getDataSource();   // the owned pool, if you need it
config.dataSource(existingDataSource);