users@glassfish.java.net

Re: Relationship navigation in java code failing to get properly populated list

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Fri, 23 Feb 2007 14:35:53 -0800

Jeff,

How do Asset and AssetPropertyType relate to each other?

thanks,
-marina

glassfish_at_javadesktop.org wrote:
> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>