[hibernate-dev] Is bytecode enhancement enabled by default in 5.3?

Steve Ebersole steve at hibernate.org
Wed May 23 09:17:22 EDT 2018


I never understood this `DataSourceDefinitions` part.  Why can't they just
be discovered via jipijapa prior to doing anything with Hibernate/JPA?

See inline...

Steve Ebersole and I have talked about adding additional phases to the
> PU bootstrap, but that was so long ago, I forget if it was about
> registering the ORM class transformer [1] earlier.  If ORM 5.3 or 6.0,
> is depending on [1] to work correctly in order to implement the ORM
> features, we need to take some action.
>

So the rub right now (up through and including) 5.3 is that we sometimes
load domain model Class references during this "first bootstrap phase".
What really needs to happen is for Hibernate to unequivocally delay loading
domain model Class references until after this phase is over - at least
delay loading them into the "real" ClassLoader, we can use the JPA temp
ClassLoader if it is available.

6.0 will delay loading these Class references even more so than today.
However, even with 6.0 we cannot fully guarantee that we will never load
them during this 1st phase.  That is a design goal for 7.0 and the move to
Jandex.



> In the past, I recall someone mentioning that lazy loading or dirty flag
> handling, would depend on bytecode enhancing.  If that happened or will
> happen, we should discuss what the fallback solution is for when
> bytecode enhancing is not working.
>

Bytecode enhancement is not needed for either of these - Hibernate can (and
has forever) supported these without enhancement.  That will continue to be
the case.  Bytecode enhancement is simply an alternative means for adding
these features.

However, certain features such as automatic bi-dir association management
does require enhancement to work.



> Another subject, is how should a user find out that bytecode enhancing
> is actually updating application entity classes.  Should that operation
> have trace logging and should that be at the WF or ORM level?
>

Well based on what you described it sounds to me like there ought to be at
least 2 different log events here:

   1. The transformer is registered (this could be either WF or Hibernate
   or both)
   2. The transformer calls the Enhancer
   3. (?) Enhancer enhances a class.  Enhancer is an interface though and
   this would rely on the impls (Javassist and Byte Buddy) to do this.


More information about the hibernate-dev mailing list