-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Align bytecode enhancement behavior on Quarkus in QuarkusLikeORMUnitT…
…estCase
- Loading branch information
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/QuarkusLikeEnhancementContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.hibernate.bugs; | ||
|
||
import org.hibernate.bytecode.enhance.spi.DefaultEnhancementContext; | ||
import org.hibernate.bytecode.enhance.spi.UnloadedField; | ||
import org.hibernate.bytecode.enhance.spi.UnsupportedEnhancementStrategy; | ||
|
||
public class QuarkusLikeEnhancementContext extends DefaultEnhancementContext { | ||
@Override | ||
public boolean doBiDirectionalAssociationManagement(final UnloadedField field) { | ||
//Don't enable automatic association management as it's often too surprising. | ||
//Also, there's several cases in which its semantics are of unspecified, | ||
//such as what should happen when dealing with ordered collections. | ||
return false; | ||
} | ||
|
||
@Override | ||
public UnsupportedEnhancementStrategy getUnsupportedEnhancementStrategy() { | ||
// We expect model classes to be enhanced. | ||
// Lack of enhancement could lead to many problems, | ||
// from bad performance, to Quarkus-specific optimizations causing errors/data loss, | ||
// to incorrect generated bytecode (references to non-existing methods). | ||
// If something prevents enhancement, it's just safer to have Hibernate ORM's enhancer fail | ||
// with a clear error message pointing to the application class that needs to be fixed. | ||
return UnsupportedEnhancementStrategy.FAIL; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters