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

Spring Boot

Auto-configuration that reuses your application DataSource, the jehibernate.* properties, and the @JEHibernateRepositoryTest slice.
Updated last month
Migrations
Spigot & Paper Plugins
The jehibernate-spring-boot starter auto-configures JEHibernate against your application's DataSource. There is no @Bean wiring to write.
implementation("de.jexcellence.hibernate:jehibernate-spring-boot:4.2.0")

How it activates

When a DataSource bean is present, the auto-configuration registers a JEHibernate bean that reuses that DataSource (Spring's pool — JEHibernate never closes it) and a RepositoryRegistry. It runs after DataSourceAutoConfiguration and is driven by jehibernate.* properties.
@Service
class WarpService {
    private final WarpRepository warps;
    WarpService(JEHibernate jeHibernate) {           // injected, auto-configured
        this.warps = jeHibernate.repositories().get(WarpRepository.class);
    }
}

Properties

spring:
  datasource:
    url: jdbc:postgresql://localhost:5432/app
    username: app
    password: secret
jehibernate:
  database: POSTGRESQL
  ddl-auto: validate
  scan-packages: [com.example.domain]
  migration-enabled: false   # let Spring Boot's own Flyway own migrations
  enabled: true              # set false to turn the auto-config off entirely
Because Spring Boot has first-class Flyway/Liquibase support, it is usually cleanest to let Spring run migrations (migration-enabled: false) and keep JEHibernate at ddl-auto: validate.

Overriding the auto-configuration

Define your own JEHibernate @Bean and the auto-configuration backs off (@ConditionalOnMissingBean). This is the hook for programmatic configuration — a custom pool, multi-tenancy, audit:

Testing with @JEHibernateRepositoryTest

A @DataJpaTest analog: it boots a minimal context with an embedded DataSource plus the JEHibernate auto-configuration — no Docker, fast.
Attributes map onto jehibernate.*: database, ddlAuto, scanPackages, migrationEnabled.
Spring's DataSource wins
In Spring, prefer config.dataSource(...) (the default auto-config behaviour) so there is a single pool. JEHibernate manages the SessionFactory, not the connections.
@Bean
JEHibernate jeHibernate(DataSource dataSource) {
    return JEHibernate.builder()
        .configuration(c -> c.dataSource(dataSource).ddlAuto("validate").enableAudit())
        .scanPackages("com.example.domain")
        .build();
}
@JEHibernateRepositoryTest(scanPackages = "com.example.domain")
class WarpRepositoryTest {

    @Autowired JEHibernate jeHibernate;

    @Test
    void createsAndReads() {
        var repo = jeHibernate.repositories().get(WarpRepository.class);
        var saved = repo.create(new Warp("spawn"));
        assertThat(repo.findById(saved.getId())).isPresent();
    }
}