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