The Hibernate API alone does not allow you to do this programmatically, as I know. The docs say that you can specify the isolation level as a configuration property:
hibernate.connection.isolation - Sets the isolation level of a JDBC transaction. Check java.sql.Connection connection for meaningful values
But of course this applies to the entire SessionFactory , and not just to specific requests.
It is tempting to bother with the basic isolation level of java.sql.Connection , but I would be very careful about this, you run the risk of hibernate locking strategies that use the JDBC isolation level to determine which LockMode will be used. If you change this directly to Connection, you may get odd results. Of course, you may not have a choice, but be careful.
The โbestโ solution would be to use the Hibernate Spring Transaction API , which allows you to separate transaction semantics, such as the isolation level from the Hibernate API, in a completely, predictable and reliable way.
source share