users@glassfish.java.net

Relationship navigation in java code failing to get properly populated list

From: <glassfish_at_javadesktop.org>
Date: Fri, 23 Feb 2007 12:53:57 PST

Hi all, thanks for reading my post.

Quick overview of my objects (the pieces that I think matter) in pseudo code:
AssetClass {
  @OneToMany(cascade=CascadeType.ALL, mappedBy="assetClass")
  List<AssetPropertyType> properties = new ArrayList<AssetPropertyType>();
}

AssetPropertyType {
  @ManyToOne
  AssetClass assetClass;
}

Asset {
  @ManyToOne
  AssetClass assetClass;
}

Now that that's out of the way, it seems that if I try to navigate to the properties list from my asset, that the list only contains one entry. That is:
asset.assetClass.properties does not contain all the elements that it should. Note that I'm iterating over the list with the enhanced for loop.

However, if I load the asset class into toplink FIRST, the list IS populated properly.

Additionally, it seems that if I get the properties as a list unto itself, it IS populated properly and I can iterate it just fine with the enhanced for loop:
List<AssetPropertyType> properties = asset.assetClass.properties

Is there some gotcha that's "got" me right now?

Thanks,
Jeff
[Message sent by forum member 'jeffreyrodriguez' (jeffreyrodriguez)]

http://forums.java.net/jive/thread.jspa?messageID=205026