You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by CG <le...@gmail.com> on 2009/02/06 19:52:15 UTC
Lazy fetch problem , null value
I am using openjpa 1.0.3 that come with Apache Geronimo 2.1.3, I am
facing problem with the Lazy fetch ...
Material is an EntityBean
public class Material extends BaseEntity
{
:
:
@OneToMany(cascade=CascadeType.ALL, fetch = FetchType.LAZY,
mappedBy="material", targetEntity=BOM.class)
private List<BOM> boms;
@OneToMany(cascade=CascadeType.ALL, fetch = FetchType.LAZY,
mappedBy="material", targetEntity=BomDetail.class)
private List<BomDetail> bomDetails;
:
:
public BOM getBomByType(String type)
{
System.out.println("boms = " + getBoms());
if(boms != null)
{
for(BOM bom : boms)
{
//System.out.println("[Material.java]
getBomByType() : " + bom.getType() + " type : " + type);
if(bom.getType().equals(type))
{
//System.out.println("Before
return bom");
return bom;
}
}
}
else
{
System.out.println("[Material.java] boms is null");
}
return null;
}
}
If I use Lazy Fetch for boms - when calling getBomByType() , the output is :
[Material.java] boms is null
I hv do google search , somebody suggest to use property access , but
I hv tried that it still does not work.
I am now hv no idea how to continue to debug , eventhough using Eager
does work, but in my case , I hv to use Lazy fetch because is
populating a tree structure ..
Any help is much appreaciated , thanks
cheers,
CG