Instantiate the LAZY relationship prior to serialization
593615Aug 18 2007 — edited Aug 21 2007I have several class in my project example:
class X{
@OneToMany(cascade = CascadeType.ALL, mappedBy = "...")
Collection<XChild> child;
}
class XChild{
@OneToMany(cascade = CascadeType.ALL, mappedBy = "...")
Collection <XChildChild> child_child;
}
class XChildChild{
}
When I request object X I want to get XChild and their XChildChild but
I don't want to use EAGER fetch type.
How to made query?
Sqting sql = "select x from X as x join fetch x.child child join fetch child.child_child"
dont work.
Exception is:
An attempt was made to traverse a relationship using indirection that had a null Session. This often occurs when an entity with an uninstantiated LAZY relationship is serialized and that lazy relationship is traversed after serialization. To avoid this issue, instantiate the LAZY relationship prior to serialization.
Thanks a lot.
D.S