I am getting an OutOfMemoryError upon executing a findFiltered( ) query with a bi-directional one-to-many Hibernate relationship. The stack trace is attached. It seems the code is in an infinite loop due to the circular references.
Here is an example of the relationship:
class Parent {
private Long id;
private Set<Child> children;
... other fields and code
}
class Child {
private Long id;
private Parent parent; // needed for foreign key relationship
... other fields and code
}
Test code:
public Parent findByChildren(Set<Child> children)
{
Parent parent = new Parent();
parent.setChildren(children);
bshd5DAO.findFiltered(parent); // OutOfMemoryError here
}
This is a known issue in the current EnhancedExample implementation. What happens in your case is:
I am afraid with the current implementation, you need to adopt one of the following workarounds:
This is one of the limitations of the current implementation and will be resolved on the next release.