|
52 | 52 | import org.hibernate.bytecode.enhance.spi.EnhancementException;
|
53 | 53 | import org.hibernate.bytecode.enhance.spi.UnloadedClass;
|
54 | 54 | import org.hibernate.bytecode.enhance.spi.UnloadedField;
|
| 55 | +import org.hibernate.bytecode.spi.BytecodeProvider; |
55 | 56 | import org.hibernate.bytecode.spi.ClassTransformer;
|
56 | 57 | import org.hibernate.cfg.AvailableSettings;
|
57 | 58 | import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
|
113 | 114 | import static org.hibernate.cfg.AvailableSettings.TRANSACTION_COORDINATOR_STRATEGY;
|
114 | 115 | import static org.hibernate.cfg.AvailableSettings.URL;
|
115 | 116 | import static org.hibernate.cfg.AvailableSettings.USER;
|
| 117 | +import static org.hibernate.cfg.BytecodeSettings.BYTECODE_PROVIDER_INSTANCE; |
116 | 118 | import static org.hibernate.cfg.BytecodeSettings.ENHANCER_ENABLE_ASSOCIATION_MANAGEMENT;
|
117 | 119 | import static org.hibernate.cfg.BytecodeSettings.ENHANCER_ENABLE_DIRTY_TRACKING;
|
118 | 120 | import static org.hibernate.cfg.BytecodeSettings.ENHANCER_ENABLE_LAZY_INITIALIZATION;
|
@@ -422,6 +424,11 @@ protected EnhancementContext getEnhancementContext(
|
422 | 424 | final boolean dirtyTrackingEnabled,
|
423 | 425 | final boolean lazyInitializationEnabled,
|
424 | 426 | final boolean associationManagementEnabled ) {
|
| 427 | + final Object propValue = configurationValues.get( BYTECODE_PROVIDER_INSTANCE ); |
| 428 | + if ( propValue != null && ( ! ( propValue instanceof BytecodeProvider ) ) ) { |
| 429 | + throw new PersistenceException( "Property " + BYTECODE_PROVIDER_INSTANCE + " was set to '" + propValue + "', which is not compatible with the expected type " + BytecodeProvider.class ); |
| 430 | + } |
| 431 | + final BytecodeProvider overriddenBytecodeProvider = (BytecodeProvider) propValue; |
425 | 432 | return new DefaultEnhancementContext() {
|
426 | 433 |
|
427 | 434 | @Override
|
@@ -461,6 +468,11 @@ public boolean doExtendedEnhancement(UnloadedClass classDescriptor) {
|
461 | 468 | // doesn't make any sense to have extended enhancement enabled at runtime. we only enhance entities anyway.
|
462 | 469 | return false;
|
463 | 470 | }
|
| 471 | + |
| 472 | + @Override |
| 473 | + public BytecodeProvider getBytecodeProvider() { |
| 474 | + return overriddenBytecodeProvider; |
| 475 | + } |
464 | 476 | };
|
465 | 477 | }
|
466 | 478 |
|
|
0 commit comments