How to get the default transaction isolation level using Hibernate API


#1

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


#2

When using Hibernate API:

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

When using JPA:

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

#3

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


#4

Hibernate uses the underlying DB isolation level.


#5

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


#6

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.