openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simone Gianni <>
Subject Re: OneToMany lazy loading
Date Thu, 05 Mar 2009 17:35:22 GMT
Hi Ram,
looking at your snippet, I see that you declared the field public. Are 
you then trying to access it using parent.TableB_Obj ? Cause in that 
case I don't think OpenJPA is able to catch your call and load the 
collection when needed. Try declaring the field private, creating a 
getter, and using the getter to access it. I use getters and lazy 
loading works correctly.

Hope this helps,


RamAESIS wrote:
> Hi,
> I am trying to lazy load a child collection in a one-to-many relationship as
> shown below:
>       @OneToMany(cascade=CascadeType.ALL,fetch=FetchType.LAZY)
>       @ElementJoinColumns({
>            @ElementJoinColumn(name="ColA",referencedColumnName="ColX"),
>            @ElementJoinColumn(name="ColB",referencedColumnName="ColY"),
>            @ElementJoinColumn(name="ColC",referencedColumnName="ColZ")
>       })
>       public Collection<TableB> TableB_Obj = new HashSet<TableB>();
> But after accessing the child collection  also it is still NULL, EAGER mode
> works properly. Any guess or guidance in this issue is highly appreciated.
> Thanks in advance.
> Regards,
> Ram

Simone Gianni            CEO Semeru s.r.l.           Apache Committer

View raw message