users@glassfish.java.net

Re: Relationship NOT marked cascade PERSIST

From: <glassfish_at_javadesktop.org>
Date: Mon, 18 Feb 2008 09:45:44 PST

Mitesh:

  Thank you for taking the time out and reponding to my question. What I have tried to accomplish is remove the complexity from the design by removing bidirectional relationships where I could. I accomplished this as follows:

@OneToOne(optional=true, fetch=FetchType.LAZY)

When I started creating each of the entities, I null the values when I did not want a relationship. My thinking was this approach would allowed me the ability to create the relationships at a later time when more information was available.

My population would be something very simple, such as the following:

                                Asset asset2 = new Asset();
                                asset2.setAssetArtifact("Blah Blah");
                                asset2.setAssetImage("Yeppi Skippie");
                                asset2.setAssetMaintenanceHistories(null);
                                asset2.setAssetOrigDate(new Date(Calendar.getInstance().getTimeInMillis()));
                                asset2.setAssetType(assetType);
                                asset2.setCageCode("Cage Code 12B-345");
                                asset2.setConsumables(consumeSet);
                                asset2.setDateDecommissioned(new Date(Calendar.getInstance().getTimeInMillis()));
                                asset2.setDatePlacedInService(new Date(Calendar.getInstance().getTimeInMillis()));
                                asset2.setGovFurnishEquipAssetId("GFE123890678962356824389243");
                                asset2.setItemPart(item);
                                asset2.setManufacturer(manufacturer);
                                asset2.setModel(model);
                                asset2.setNsn("12345678900987654321");
                                asset2.setPemaAsset(null);
                                asset2.setProdModelName("THE BIG TEST MODEL");
                                asset2.setProductDo("Mary had a little lamb");
                                asset2.setSerialNbr("213120891239u4598473578-5");
                                asset2.setServerAsset(null);
                                asset2.setTradingPartner(tradePartner);
                                asset2.setWarranties(warrantySet);

Any advice would be greatly appreciated.

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

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