|
20 | 20 |
|
21 | 21 | import org.hibernate.testing.boot.BasicTestingJdbcServiceImpl;
|
22 | 22 | import org.hibernate.testing.orm.junit.BaseSessionFactoryFunctionalTest;
|
| 23 | +import org.hibernate.testing.orm.junit.Jira; |
23 | 24 | import org.hibernate.testing.orm.junit.RequiresDialect;
|
24 | 25 | import org.hibernate.testing.orm.jdbc.PreparedStatementSpyConnectionProvider;
|
25 | 26 | import org.junit.jupiter.api.AfterEach;
|
@@ -118,9 +119,9 @@ protected void cleanupTest() throws Exception {
|
118 | 119 |
|
119 | 120 | @Test
|
120 | 121 | public void testBasicRelease() {
|
121 |
| - connectionProvider.clear(); |
122 | 122 | ResourceRegistry registry = sessionFactoryScope().fromSession(
|
123 | 123 | session -> {
|
| 124 | + connectionProvider.clear(); |
124 | 125 | JdbcCoordinatorImpl jdbcCoord = (JdbcCoordinatorImpl) session.getJdbcCoordinator();
|
125 | 126 | ResourceRegistry resourceRegistry = jdbcCoord.getLogicalConnection().getResourceRegistry();
|
126 | 127 | try {
|
@@ -155,9 +156,9 @@ public void testBasicRelease() {
|
155 | 156 |
|
156 | 157 | @Test
|
157 | 158 | public void testReleaseCircumventedByHeldResources() {
|
158 |
| - connectionProvider.clear(); |
159 | 159 | ResourceRegistry registry = sessionFactoryScope().fromSession(
|
160 | 160 | session -> {
|
| 161 | + connectionProvider.clear(); |
161 | 162 | JdbcCoordinatorImpl jdbcCoord = (JdbcCoordinatorImpl) session.getJdbcCoordinator();
|
162 | 163 | ResourceRegistry resourceRegistry = jdbcCoord.getLogicalConnection().getResourceRegistry();
|
163 | 164 |
|
@@ -219,10 +220,9 @@ public void testReleaseCircumventedByHeldResources() {
|
219 | 220 |
|
220 | 221 | @Test
|
221 | 222 | public void testReleaseCircumventedManually() {
|
222 |
| - connectionProvider.clear(); |
223 |
| - connectionProvider.clear(); |
224 | 223 | ResourceRegistry registry = sessionFactoryScope().fromSession(
|
225 | 224 | session -> {
|
| 225 | + connectionProvider.clear(); |
226 | 226 | JdbcCoordinatorImpl jdbcCoord = (JdbcCoordinatorImpl) session.getJdbcCoordinator();
|
227 | 227 | ResourceRegistry resourceRegistry = jdbcCoord.getLogicalConnection().getResourceRegistry();
|
228 | 228 |
|
@@ -275,4 +275,20 @@ public void testReleaseCircumventedManually() {
|
275 | 275 | assertEquals( 0, connectionProvider.getAcquiredConnections().size() );
|
276 | 276 | assertEquals( 2, connectionProvider.getReleasedConnections().size() );
|
277 | 277 | }
|
| 278 | + |
| 279 | + @Test |
| 280 | + @Jira("https://hibernate.atlassian.net/browse/HHH-19477") |
| 281 | + public void testHql() { |
| 282 | + sessionFactoryScope().inTransaction( session -> { |
| 283 | + connectionProvider.clear(); |
| 284 | + JdbcCoordinatorImpl jdbcCoord = (JdbcCoordinatorImpl) session.getJdbcCoordinator(); |
| 285 | + ResourceRegistry resourceRegistry = jdbcCoord.getLogicalConnection().getResourceRegistry(); |
| 286 | + |
| 287 | + session.createSelectionQuery( "select 1" ).uniqueResult(); |
| 288 | + |
| 289 | + assertFalse( resourceRegistry.hasRegisteredResources() ); |
| 290 | + assertEquals( 0, connectionProvider.getAcquiredConnections().size() ); |
| 291 | + assertEquals( 1, connectionProvider.getReleasedConnections().size() ); |
| 292 | + } ); |
| 293 | + } |
278 | 294 | }
|
0 commit comments