After upgrading from Hibernate 5.3 to Hibernate 6.2,An error occurred when reading lazy field due to a casting issue

Project Background: Architecture upgrade, upgrading from Spring 5 to 6.1.5 and Hibernate from 5.3 to 6.2.25, non-Maven project
Issue: After the upgrade, there are casting errors occurring during requests, with the following error message:
class org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer$1 cannot be cast to class java.lang.String (org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer$1 is in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @5b068087; java.lang.String is in module java.base of loader ‘bootstrap’)
Analysis Process: It should be caused by changes in the Hibernate bytecode enhancer, or changes in the initialization of large fields and proxy modes,
I have read the official migration guide:

considering our project’s bytecode enhancement approach as well,

this enhancement approach had no issues in version 5.3, but problems occurred after the upgrade. Is it possible that this bytecode enhancement approach is no longer compatible? This is based on the findings from the migration guide,‘hibernate.enhancer.enableLazyInitialization’,‘hibernate.enhancer.enableDirtyTracking’,both values have been set to true by default and have been deprecated. Can we remove the enhancement approach used in our project? After removal, will the lazy properties’ fields still be able to be proxied and read normally, or are there new enhancement approaches available? If there are, please provide the new bytecode enhancement API that can be adapted to our project.Thanks!

Please try to create a reproducer with our test case template and if you are able to reproduce the issue, create a bug ticket in our issue tracker and attach that reproducer.

You just need to answer me whether there have been changes in the bytecode enhancement approach in Hibernate, and if so, what is the specific implementation of the enhancement approach, and whether you can provide the corresponding implementation API.

The Hibernate ORM releases 5.3 and 6.2 are approximately 5 years apart, so no, nobody can “just” tell you if something changed. Most probably something changed yeah. Simply replacing the bytecode enhancer with a custom implementation is not something that is supported, so if you want help, you will have to provide a reproducer that can be examined by other people. Just posting pictures and text is not enough for such a complicated topic.