users@glassfish.java.net

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

From: Markus Fuchs <Markus.Fuchs_at_Sun.COM>
Date: Fri, 23 Feb 2007 14:35:14 -0800

Hi Jeffrey,

The JPA specification recommends, that relationships are maintained from
both sides. I.e. when setting the relationship
assetPropertyType.assetClass, the application must also do
assetClass.properties.add(assetClass). Can this be the problem?

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,
What does "get the properties as a list unto itself " mean?

Thanks,

-- markus.
> 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
>
>