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.
In Spring, prefer config.dataSource(...) (the default auto-config behaviour) so there is a single pool. JEHibernate manages the SessionFactory, not the connections.