|
Similar code as above, but the private member variable is not being initialized to a default value:
private Set<Child> children;
@OneToMany(mappedBy = "parent")
public Set<Child> getChildren() {
return children;
}
Bytecode instrumentation is enabled via the Maven plugin:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<configuration>
<tasks>
<taskdef name="instrument" classname="org.hibernate.tool.instrument.javassist.InstrumentTask">
<classpath>
<path refid="maven.runtime.classpath"/>
<path refid="maven.plugin.classpath"/>
</classpath>
</taskdef>
<instrument verbose="false">
<fileset dir="${project.build.outputDirectory}">
<include name="**/model/**/*.class"/>
</fileset>
</instrument>
</tasks>
</configuration>
</plugin>
Verified using hibernate-core versions 5.0.2.Final and 5.0.3.Final:
-
first invocation of parent.getChildren() returns the correct Set instance,
-
but the following invocations of parent.getChildren() all return null instead.
If the bytecode instrumentation is disabled, everything works as expected again. Adding the fetch = FetchType.LAZY argument to the @OneToMany does not seem to make a difference.
|