How to get the default transaction isolation level using Hibernate API

Can I get default transaction isolation level using Hibernate’s API?

When using Hibernate API:

int isolationLevel = session.doReturningWork(Connection::getTransactionIsolation);

When using JPA:

int isolationLevel = entityManager.unwrap(Session.class)
	.doReturningWork(Connection::getTransactionIsolation);
1 Like

If I don’t set hibernate isolation level through the property then what is the default isolation level used by hibernate?

Hibernate uses the underlying DB isolation level.

1 Like

Can I override the underlying database isolation level through hibernate? If yes then how?

It all depends on what connection provider you use. For DataSource ConnectionPprovider, set it at Connection Pool level. For other Connection Providers, just set the hibernate.connection.isolation property.

1 Like