Skip to content

Commit d8b84b5

Browse files
committed
Fail the build instead of skipping Hibernate ORM bytecode enhancement when it's unsupported
1 parent 9304a59 commit d8b84b5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/integration/QuarkusEnhancementContext.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.hibernate.bytecode.enhance.spi.DefaultEnhancementContext;
44
import org.hibernate.bytecode.enhance.spi.UnloadedField;
5+
import org.hibernate.bytecode.enhance.spi.UnsupportedEnhancementStrategy;
56

67
public final class QuarkusEnhancementContext extends DefaultEnhancementContext {
78

@@ -26,4 +27,15 @@ public ClassLoader getLoadingClassLoader() {
2627
throw new IllegalStateException("The Classloader of the EnhancementContext should not be used");
2728
}
2829

30+
@Override
31+
public UnsupportedEnhancementStrategy getUnsupportedEnhancementStrategy() {
32+
// We expect model classes to be enhanced.
33+
// Lack of enhancement could lead to many problems,
34+
// from bad performance, to Quarkus-specific optimizations causing errors/data loss,
35+
// to incorrect generated bytecode (references to non-existing methods).
36+
// If something prevents enhancement, it's just safer to have Hibernate ORM's enhancer fail
37+
// with a clear error message pointing to the application class that needs to be fixed.
38+
return UnsupportedEnhancementStrategy.FAIL;
39+
}
40+
2941
}

0 commit comments

Comments
 (0)