| A stack trace at this point would be nice. My guess is that something causes the "original Connection" (as defined by this SessionTransactionData#preparedCon) to get released and then the call for the "current Connection" (reflectively accessed via SessionImpl#connection) gets a new Connection. But I am not really setup to debug Spring; nor would that really be within my core competency set. Another option would be to play around with the hibernate.connection.acquisition_mode setting added in 5.1. It was an incubating feature, and how you specify this changed in 5.2, but it works the same in both once specified: namely, if set to org.hibernate.ConnectionAcquisitionMode#AS_NEEDED (the legacy and default value) Connections will be released and (re)acquired as needed (within rules). However the new feature there is org.hibernate.ConnectionAcquisitionMode#IMMEDIATELY which forces Hibernate to immediately (as soon as the Session is opened) acquire the JDBC Connection and hold on to it for the duration of the Session being open. |