I am having similar issues like this one here [HHH-13242] - Hibernate JIRA that is marked as fixed but not sure why. We had custom ByteCodeProvider with hibernate5 but when we moved to hibernate6 then our provider is just being ignored. Seems like this code in EntityRepresentationStrategyPojoStandard class
final BytecodeProvider bytecodeProvider = Environment.getBytecodeProvider();
is not allowing to use custom byte provider. When this is changed to
final BytecodeProvider bytecodeProvider = creationContext.getBootstrapContext().getServiceRegistry().getService(BytecodeProvider.class);
then our custom bytecode provider is used and works as expected.
What is proper way to configure custom ByteCodeProvider in Hibernate6?
It’s the first time I hear of anyone actually being brave enough to maintain a custom BytecodeProvider; indeed I don’t think it’s currently configurable - I have it on my wishlist for things to improve sometime soon to remove the global environment settings; that’s why these methods are marked as deprecated. Haven’t had a chance to work on it but I appreciate the existence of such system properties require some clarifications.
I’ll try to find some time to remove the misleading properties; we can then also take in consideration to allow integrating a custom one.
Could you give me an idea of why you need a custom implementation?
Ideally I’d want to evolve this in small steps:
Remove the static & global aspects, allowing only a regular configuration property to set either “bytebuddy” or “none”. Allow overrides to happen via a ServiceInitiator.
Move the ByteBuddy enhancer into a separate jar, making it optional.
(Optionally, pending your feedback) Allow to drop in a different implementation instead of the ByteBuddy based implementation.
You might not have to give up on it: we might re-introduce the capability if there’s good reasons but if we can have your need covered in a simpler way that might be preferrable.
What do you mean by “compile time proxy”? Are these different from the build time enhancers we already provide?