This bug is still present in 5.4.1.Final and is easily reproducible as the original post describes: just call a lazy load getter outside of an active transaction and you get a connection leak, causing the connection pool to get filled very qickly (using hikari in our application). I believe this goes hand in hand with the fact that org.hibernate.ConnectionReleaseMode by default only releases the connection after a transaction. Since there is no transaction, connection leaks. Putting the lazy load getter calls inside a transaction solves this problem, however, one should not really need to start transactions just to call some getters on an entity (I think?). Eclipselink in comparision releases the connection properly as one would expect. Hopefully hibernate would be willing to change this behaviour or at least add a release mode option that would mimic the desired effect specified in the original post. I can also provide a test case for hibernate 5, although I don't think anything changed since the original report. |