Class AuditLogFactory
java.lang.Object
org.hibernate.audit.AuditLogFactory
Factory for obtaining
AuditLog instances.
Two creation modes are supported:
- Standalone (from
SessionFactoryorEntityManagerFactory): opens its own JDBC connection. Use when no session is available. - Connection-sharing (from
Session,StatelessSession, orEntityManager): shares the session's JDBC connection. Use when a session is already open.
AuditLog is AutoCloseable and
should be closed by the caller to release the internal session.
For connection-sharing instances, the audit log is also
automatically closed when the parent session closes.- Since:
- 7.4
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic AuditLogcreate(EntityManager entityManager) Create an audit log sharing the entity manager's JDBC connection.static AuditLogcreate(EntityManagerFactory entityManagerFactory) Create a standalone audit log.static AuditLogCreate an audit log sharing the session's JDBC connection.static AuditLogcreate(SessionFactory sessionFactory) Create a standalone audit log.static AuditLogcreate(StatelessSession session) Create an audit log sharing the stateless session's JDBC connection.
-
Method Details
-
create
Create a standalone audit log.- Parameters:
sessionFactory- the session factory- Returns:
- a new audit log (must be closed by the caller)
-
create
Create a standalone audit log.- Parameters:
entityManagerFactory- the entity manager factory- Returns:
- a new audit log (must be closed by the caller)
-
create
-
create
Create an audit log sharing the stateless session's JDBC connection.- Parameters:
session- the stateless session whose connection to share- Returns:
- a new audit log (must be closed by the caller)
-
create
Create an audit log sharing the entity manager's JDBC connection.- Parameters:
entityManager- the entity manager whose connection to share- Returns:
- a new audit log (must be closed by the caller)
-