From: Petko D. <pe...@mu...> - 2004-09-27 10:37:58
|
hi all, I have some problems with value objects. so here is the example: Company with two type of addresses. like the example here http://xdoclet.sourceforge.net/xdoclet/valueobjects.html i consider the address to be composition. It can be an aggregation too, but composition fits my case. so here is my source: ... /** * @return address for correspondence * @ejb.relation * name = "companyInfo-addressCor-1-1" * role-name = "companyInfo" * target-ejb="Address" * target-role-name="addressCor" * target-cascade-delete="yes" * * @ejb.interface-method * view-type="local" * * @jboss.relation * related-pk-field="addressId" * fk-column="address_Cor_id" * * @ejb.value-object * compose="com.leasing.business.AddressValue" * compose-name="AddressCorValue" * relation="external" * */ public abstract AddressLocal getAddressCorLocal(); /** * @param address * @ejb.interface-method * view-type="local" * */ public abstract void setAddressCorLocal( AddressLocal addressCorLocal); /** * @return registration address * @ejb.relation * name = "companyInfo-addressReg-1-1" * role-name = "companyInfo" * target-ejb="Address" * target-role-name="addressReg" * target-cascade-delete="yes" * * @ejb.interface-method * view-type="local" * * @jboss.relation * related-pk-field="addressId" * fk-column="address_Reg_id" * * @ejb.value-object * compose="com.leasing.business.AddressValue" * compose-name="AddressRegValue" * relation="external" * */ public abstract AddressLocal getAddressRegLocal(); /** * @param address * @ejb.interface-method * view-type="local" */ public abstract void setAddressRegLocal( AddressLocal addressRegLocal); ... Difference between that and EmployeeBean Sample of xdoclet is in fact only that i Use compose instead of aggregate. But the generated code have errors: here is the CompanyInfoCMP: ... // Anonymous block to allow variable declations without conflicts { // Checks for null composition if (valueHolder.getAddressCorValue() != null) { java.lang.Integer pk = valueHolder.getAddressCorValue().getAddressId(); com.leasing.business.AddressLocalHome home = com.leasing.business.AddressUtil.getLocalHome(); com.leasing.business.AddressLocal relation = home.findByPrimaryKey(pk); relation.setAddressCorValue(valueHolder.getAddressCorValue()); } } // Anonymous block to allow variable declations without conflicts { // Checks for null composition if (valueHolder.getAddressRegValue() != null) { java.lang.Integer pk = valueHolder.getAddressRegValue().getAddressId(); com.leasing.business.AddressLocalHome home = com.leasing.business.AddressUtil.getLocalHome(); com.leasing.business.AddressLocal relation = home.findByPrimaryKey(pk); relation.setAddressRegValue(valueHolder.getAddressRegValue()); } } ... and the problem: AddressLocal interface didn't have method setAddressCorValue neither setAddressRegValue. Only setAddressValue. And i didn't need that methods. As i see the difference between composition and aggregation is only chat in aggredation setXxxValue i didn't set the data. Only the relation. In my case i need to set data. Thats why i'm using composition. I can write some business methods in AddressBean - setAddressCorValue and setAddressRegValue , but they will do the same as setAddressValue.Think it's not good. What you think about that? Thaks in advance for your answers. Petko. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.766 / Virus Database: 513 - Release Date: 17.9.2004 a. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.766 / Virus Database: 513 - Release Date: 17.9.2004 a. |