When entityManager.getReference() method is invoked, the transaction interceptor (@Transactional) is executed and the commit is done but at this moment without involving any connection to the database.
After that, when a proxy fires a load event, it opens a connection and performs the query, but the close() method is never invoked causing the connection to remain active in the pool and never be released.
I have based my sample on projects of Hibernate repo. Following the example of hibernate-demo (cdi-jpa-testing) I made a sample project with Hibernate 5.4.2/5.4.3 and Agroal (test).
After running into connection leaks with "Arjuna TransactionalDriver", I tried with "hibernate-agroal" but using a custom AgroalConnectionProvider (enabling transaction integration) with same result.
java 8 (1.8.0_201)
Hibernate 5.4.3 / 5.4.2
CDI 2 (Weld 3.1.0)
Hibernate-agroal 5.4.2/5.4.3 or Arjuna TransactionalDriver
Agroal with Narayana Transaction Integration