When the in-line dirty tracking bytecode enhancement is enabled (the enableDirtyTracking parameter of the hibernate-enhance-maven-plugin's configuration is true), and an entity with an @Embeddable property is constructed by setting this field to null in the constructor, a NullPointerException is thrown from the following location:
The interesting code snippets in the bytecode enhanced entity are as follows:
The myTestEmbeddable argument of the constructor is null, so $$_hibernate_write_myTestEmbeddable() is called with a null argument. The $$_hibernate_attributeInterceptor field is not initialized in the constructor, so $$_hibernate_getInterceptor() always returns null. Because of this, the conditional code #4 is not run. In #3, the null argument is written to a temporary variable, and then in #5, it's written to the myTestEmbeddable field. Afterwards in #7, it's being cast to CompositeTracker, and its $$_hibernate_setOwner is called, while the field is still null. I think this is what throws the NullPointerException.
The Java source files of the original and bytecode enhanced @Entity and @Embeddable classes are attached to this ticket.
The hibernate-enhance-maven-plugin configuration was as follows:
The description above is valid for Hibernate 5.0.8, but the same NullPointerException occurs when using Hibernate 5.1.0.