We´ve tried out the Hibernate dirty check by bytecode enhancement via the Maven plugin (hibernate-enhance-maven-plugin) in version 5.2.6. Simple JUnit tests run quite good. But we encountered strange LazyInit exceptions on OneToMany mappings when running the same code inside a JEE container (Wildfly 8) although the collection is tagged with FetchType.EAGER! When running the code without the dirty-check bytecode enhancement everything worked fine. A similar exception was reported in
HHH-11570 Closed and
HHH-11580 Closed so I tried out the Hibernate version 5.2.10 but with the same effect. The stack trace:
I don´t understand why there is a lazy init exception when the collection is configured with FetchType.EAGER:
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "alarmFilter", fetch = FetchType.EAGER)
@MapKey(name = "id")
protected Map<String, AlarmFilterParameter> parameterById;
When changing the FetchType to LAZY the exception doesn´t occur anymore... But as said before: the code works when running without the bytecode enhancement. And it also works with bytecode enhancement but outside of a container. Please let me know if you need more information about the problem. |