|
18 | 18 | import javax.persistence.spi.PersistenceUnitInfo; |
19 | 19 | import javax.sql.DataSource; |
20 | 20 |
|
| 21 | +import org.hibernate.boot.spi.MetadataImplementor; |
| 22 | +import org.hibernate.boot.spi.SessionFactoryOptions; |
21 | 23 | import org.hibernate.cache.spi.access.AccessType; |
22 | 24 | import org.hibernate.cfg.AvailableSettings; |
23 | 25 | import org.hibernate.dialect.Dialect; |
24 | 26 | import org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl; |
25 | 27 | import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl; |
26 | 28 | import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; |
| 29 | +import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess; |
| 30 | +import org.hibernate.engine.jdbc.spi.JdbcServices; |
27 | 31 | import org.hibernate.engine.spi.SessionFactoryImplementor; |
| 32 | +import org.hibernate.hql.internal.ast.HqlSqlWalker; |
| 33 | +import org.hibernate.hql.spi.id.MultiTableBulkIdStrategy; |
28 | 34 | import org.hibernate.jpa.HibernatePersistenceProvider; |
29 | 35 | import org.hibernate.persister.entity.EntityPersister; |
30 | 36 |
|
@@ -88,6 +94,7 @@ public void testPassingIntegrationJtaDataSourceOverrideForJpaJdbcSettings() { |
88 | 94 | final DataSource integrationDataSource = new DataSourceStub( "integrationDataSource" ); |
89 | 95 |
|
90 | 96 | final HibernatePersistenceProvider provider = new HibernatePersistenceProvider(); |
| 97 | +puInfo.getProperties().setProperty( AvailableSettings.HQL_BULK_ID_STRATEGY, MultiTableBulkIdStrategyStub.class.getName() ); |
91 | 98 |
|
92 | 99 | final EntityManagerFactory emf = provider.createContainerEntityManagerFactory( |
93 | 100 | puInfo, |
@@ -273,6 +280,7 @@ public DataSource getJtaDataSource() { |
273 | 280 | final Map integrationOverrides = new HashMap(); |
274 | 281 | //noinspection unchecked |
275 | 282 | integrationOverrides.put( AvailableSettings.JPA_JTA_DATASOURCE, integrationDataSource ); |
| 283 | +integrationOverrides.put( AvailableSettings.HQL_BULK_ID_STRATEGY, new MultiTableBulkIdStrategyStub() ); |
276 | 284 |
|
277 | 285 | final EntityManagerFactory emf = provider.createContainerEntityManagerFactory( |
278 | 286 | new PersistenceUnitInfoAdapter(), |
@@ -318,6 +326,7 @@ public DataSource getNonJtaDataSource() { |
318 | 326 | final DataSource override = new DataSourceStub( "integrationDataSource" ); |
319 | 327 | final Map<String,Object> integrationSettings = new HashMap<>(); |
320 | 328 | integrationSettings.put( AvailableSettings.JPA_NON_JTA_DATASOURCE, override ); |
| 329 | +integrationSettings.put( AvailableSettings.HQL_BULK_ID_STRATEGY, new MultiTableBulkIdStrategyStub() ); |
321 | 330 |
|
322 | 331 | final PersistenceProvider provider = new HibernatePersistenceProvider(); |
323 | 332 |
|
@@ -502,4 +511,34 @@ public void setName(String name) { |
502 | 511 | this.name = name; |
503 | 512 | } |
504 | 513 | } |
| 514 | + |
| 515 | +public static class MultiTableBulkIdStrategyStub implements MultiTableBulkIdStrategy { |
| 516 | + |
| 517 | +@Override |
| 518 | +public void prepare( |
| 519 | +JdbcServices jdbcServices, |
| 520 | +JdbcConnectionAccess connectionAccess, |
| 521 | +MetadataImplementor metadata, |
| 522 | +SessionFactoryOptions sessionFactoryOptions) { |
| 523 | + |
| 524 | +} |
| 525 | + |
| 526 | +@Override |
| 527 | +public void release( |
| 528 | +JdbcServices jdbcServices, JdbcConnectionAccess connectionAccess) { |
| 529 | + |
| 530 | +} |
| 531 | + |
| 532 | +@Override |
| 533 | +public UpdateHandler buildUpdateHandler( |
| 534 | +SessionFactoryImplementor factory, HqlSqlWalker walker) { |
| 535 | +return null; |
| 536 | +} |
| 537 | + |
| 538 | +@Override |
| 539 | +public DeleteHandler buildDeleteHandler( |
| 540 | +SessionFactoryImplementor factory, HqlSqlWalker walker) { |
| 541 | +return null; |
| 542 | +} |
| 543 | +} |
505 | 544 | } |
0 commit comments