Empty Collections with Hibernates @OneToMany in intellij build, but not in maven clean package

Answered

Hi all,

i am working in an older Java 8 Application with Hibernate version 5.1.17.

Sometimes after switching git branches or after changes to a persistence object the build will produce a corrupted output. Wenn using the produced .war, the application will not correctly load the LAZY @OneToMany Collection object, leaving them empty. Using the same sources in  maven with a clean build does not produce jars with this behaviour. Cleaning the chache temporally solves the issue, however it reappears after some time.
Does someone have a more permanent solution for this or can explain to me what is happening here? To Delegate the Build to maven is an option, but timeintensive, so it is more a workaround than a solution, changing to eager fetching could potentially solve the issue but is bad practice in my opinion.

Kind Regards

0
3 comments

Hi,

well possible yes. I know this problem too and it occured a few times for me. but while this bug affects your editor, this affects the already build jar. The Jar and War build fine with intellij, however when you start the war it is not possible to load elements from persistence objects that are loaded via Hibernate from the database into @OneToMany annotated Collections. Building the Project with Maven afterwards and than again with intellij resolves the issue of missing loaded data. This seems not to be the case with the tattered index/dependencies, at least not in my experience.

0

Have you tried to run "Reload" from Maven tool window after switching branch and building WAR?

0

Please sign in to leave a comment.