users@glassfish.java.net

FK is not populating for JPA- One-to-One NONDirectional Relationship

From: <glassfish_at_javadesktop.org>
Date: Sat, 01 Mar 2008 13:22:42 PST

I have a entity called Asset. It is the root entitiy. Inside the root entity are several one-to-one non-directional and one-to-many relationships. Several of these child entities possess subordinate entities and relationships. The subordinate relationships are one-to-many and one-to-one bidirectional relationships. My problem is all the relationships are getting progated correctly for the subordinate entities, but the root entitiy's one-to-one non-directional relationships are not.

This is how I am declearing the relationships within the Asset entitiy:

[code]
@OneToOne(cascade={CascadeType.MERGE,CascadeType.PERSIST, CascadeType.REFRESH }, optional=true, fetch=FetchType.LAZY)
@JoinColumn(name="<FK_inside_existing_table>", referencedColumnName="<PK_target_table>", insertable=true, updatable=true)
[/code]



This is how I set the relationships:

[code]
newAsset.setAssetType(em.find(AssetType.class, assetTypeID));
newAsset.setModel(em.find(Model.class, modelID));
newAsset.setItemPart(em.find(ItemPart.class, itemPartID));
newAsset.setTradingPartner(em.find(TradingPartner.class, tradePartnerID));
newAsset.setManufacturer(em.find(Manufacturer.class, manufacturerID));
[/code]


Any suggestions would be greatly appreciated.

Russ
[Message sent by forum member 'russ205' (russ205)]

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