Pazu stated that he thought this was a bug, but after thinking about it for a while, I'm wondering if it's more of a design issue.
Say that you have two beans, OwnerBean and ComponentBean, the latter being a component of the former. The question is, what is the scope of functionality intended by the SuperCMP.setSuperValue method? More specifically, should setSuperValue be used for both database updates and database inserts? In the case of db insertion, the method should assume that the dependent object needs to be created in the database and create it. In the case of db update, the method should assume that the object already is represented in the database, find it, and update it. These are two very different cases and I wonder how a single method could have the necessary information to distinguish between the two. Instead of setSuperValue, perhaps the value-object facilty should generate two methods, createSuperValue and updateSuperValue, which client code could call depending on the desired functionality? Comments? Thanks. Chuck -----Original Message----- From: Meyer-WillnerB [mailto:Meyer-WillnerB@;logica.com] Sent: Tuesday, October 22, 2002 2:21 AM To: Chuck.R.Irvine; xdoclet-user Subject: Re: [Xdoclet-user] Do value-objects support 1-to-1 compose relati onships? Personally, I experienced the same thing. We only have unidirectional relationships in our project. For One-to-Many it works just fine and one can see that in the CMP class the necessary code to create the dependent objects is generated. For One-to-One, however, it just like Chuck states. In setXXXValue() for an object with multiplicity one code like the attached is generated: This works if the dependent object already exists, then it can be found by its PK and the value for it can be set. However if I create a new value object graph with one-to-one relationships and call setXXXValue() on my parent object the call fails since the dependent objects don't yet exist. Is this behavior intended or not. If not, I'd happily contribute a patch to the template which would make more sense to me, i.e. check if the dependent objects with the specified PK can be found and if not call it create method and set its value. What do y'all think out there? Thanks. Bernie Attached code copied from Chucks message: { // Checks for null aggregate if (valueHolder.getResourceValue() != null) { com.sprint.fmsD.genequip.ejb.pk.ResourcePK pk = new com.sprint.fmsD.genequip.ejb.pk.ResourcePK(valueHolder.getResourceValue( ).getResourceID()); com.sprint.fmsD.genequip.ejb.interfaces.ResourceLocalHome home = com.sprint.fmsD.genequip.ejb.util.ResourceUtil.getLocalHome(); com.sprint.fmsD.genequip.ejb.interfaces.ResourceLocal relation = home.findByPrimaryKey(pk); relation.setResourceValue(valueHolder.getResourceValue()); } } } -----Urspr�ngliche Nachricht----- Von: [EMAIL PROTECTED] [mailto:Chuck.R.Irvine@;mail.sprint.com] Gesendet: Montag, 21. Oktober 2002 22:52 An: [EMAIL PROTECTED] Betreff: [Xdoclet-user] Do value-objects support 1-to-1 compose relationships? I'm trying to determine whether value-objects support 1-to-1 compose relationships. By examining the XDoclet sample project, I think I understand how 1-to-N relationships are supported, but I don't see any examples of 1-to-1 compose relationships. In an archived mailing list posting, Pazu states that parent objects in compose relationships automatically create and remove their dependent objects, and in the sample project I can see that happening for the Customer-Shipping_Address relationship. However, for a 1-to-1 relationship that I'm implementing, I don't see it happening. The relevant extracts from my Bean class and the corresponding CMP class are attached. Thanks for your help. Chuck ************************ Bean Class Extract ************************ /** * Returns related Resource * * @return related com.sprint.fmsD.genequip.ejb.interfaces.ResourceLocal * * @ejb.interface-method * view-type="local" * * @ejb.relation * name="port-resource" * role-name="port-has-resource" * target-ejb="Resource" * target-role-name="resource-has-port" * * @weblogic.column-map * foreign-key-column="RSRC_ID" * key-column="RSRC_ID" * * @ejb.value-object * match="*" * compose="com.sprint.fmsD.genequip.ejb.vo.ResourceValue" * compose-name="ResourceValue" */ public abstract ResourceLocal getResource() /** * Sets related Resource * * @param related com.sprint.fmsD.genequip.ejb.interfaces.ResourceLocal * @ejb.interface-method * view-type="local" * @param resource the new CMR value */ public abstract void setResource(ResourceLocal resource); ************************************* CMP Class Extract **************************************** /* Value Objects BEGIN */ private com.sprint.fmsD.genequip.ejb.vo.PortValue PortValue = null; public com.sprint.fmsD.genequip.ejb.vo.PortValue getPortValue() { PortValue = new com.sprint.fmsD.genequip.ejb.vo.PortValue(); try { PortValue.setPortID( getPortID() ); PortValue.setNodeResourceID( getNodeResourceID() ); PortValue.setFmsSiteNumber( getFmsSiteNumber() ); PortValue.setLineupNumber( getLineupNumber() ); PortValue.setMaintenanceUserIdentifier( getMaintenanceUserIdentifier() ); PortValue.setMaintenanceTransactionIdentifier( getMaintenanceTransactionIdentifier() ); PortValue.setMaintenanceFunctionIndicatorCode( getMaintenanceFunctionIndicatorCode() ); PortValue.setMaintenanceDate( getMaintenanceDate() ); if ( getResource() != null ) PortValue.setResourceValue( getResource().getResourceValue() ); } catch (Exception e) { throw new javax.ejb.EJBException(e); } return PortValue; } public void setPortValue( com.sprint.fmsD.genequip.ejb.vo.PortValue valueHolder ) { try { setNodeResourceID( valueHolder.getNodeResourceID() ); setFmsSiteNumber( valueHolder.getFmsSiteNumber() ); setLineupNumber( valueHolder.getLineupNumber() ); setMaintenanceUserIdentifier( valueHolder.getMaintenanceUserIdentifier() ); setMaintenanceTransactionIdentifier( valueHolder.getMaintenanceTransactionIdentifier() ); setMaintenanceFunctionIndicatorCode( valueHolder.getMaintenanceFunctionIndicatorCode() ); setMaintenanceDate( valueHolder.getMaintenanceDate() ); // Anonymous block to allow variable declations without conflicts { // Checks for null aggregate if (valueHolder.getResourceValue() != null) { com.sprint.fmsD.genequip.ejb.pk.ResourcePK pk = new com.sprint.fmsD.genequip.ejb.pk.ResourcePK(valueHolder.getResourceValue( ).getResourceID()); com.sprint.fmsD.genequip.ejb.interfaces.ResourceLocalHome home = com.sprint.fmsD.genequip.ejb.util.ResourceUtil.getLocalHome(); com.sprint.fmsD.genequip.ejb.interfaces.ResourceLocal relation = home.findByPrimaryKey(pk); relation.setResourceValue(valueHolder.getResourceValue()); } } } catch (Exception e) { throw new javax.ejb.EJBException(e); } } /* Value Objects END */ ------------------------------------------------------- This sf.net emial is sponsored by: Influence the future of Java(TM) technology. Join the Java Community Process(SM) (JCP(SM)) program now. http://ad.doubleclick.net/clk;4699841;7576298;k?http://www.sun.com/javavote _______________________________________________ Xdoclet-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-user This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you. ------------------------------------------------------- This sf.net email is sponsored by: Influence the future of Java(TM) technology. Join the Java Community Process(SM) (JCP(SM)) program now. http://ad.doubleclick.net/clk;4729346;7592162;s?http://www.sun.com/javavote _______________________________________________ Xdoclet-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-user
