I remember porting this from the Javassist implementation back in the days, I can hardly imagine that I came up with this approach.
The older Javassist enhancer had the same problem when we checked.
The decision to place this field name is made here: https://github.com/hibernate/hibernate-orm/blob/2d345fc04bf4c2df1d76d5f89bd4dfc7e60eee02/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/bytebuddy/InlineDirtyCheckingHandler.java#L121
That’s one place. It is a problem in many of the places persistentField.getName() is used.
Is the required information available at this point?
Unfortunately not. Largely this boils down to being able to understand the jakarta.persistence.AccessType in effect for each attribute, which is not a simple determination as we have to look across all fields and methods of the class and its supers. We have code that does this of course, but it is all based on the Class and reflection. And for enhancement, I’m not sure we always have access to all classes when enhancing one. |