History | Log In     View a printable version of the current page. Get help!  
Issue Details [XML]

Key: EJB-71
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Vance Karimi
Reporter: Luca Dall'Olio
Votes: (View)
Watchers: (View)
Operations

If you were logged in you would be able to see more operations.
EJB Cartridge

Composite <<Identifier>> and Value Object

Created: 24/Jul/07 11:13 AM   Updated: 15/Feb/08 09:08 AM
Component/s: None
Affects Version/s: None
Fix Version/s: None


 Description   
Mapping a composite PK using <<Identifier>> stereotype somehow breaks creation of <<ValueObject>>, since every field having the <<Identifier>> stereotype is created inside a PK embedded object, so the Entity-To-ValueObject conversion template cannot locate it.

Example :

<<Entity>>
Person
<<Identifier>> +id : Long
<<Identifier>> +tag : String
||
||
||
\/
<<ValueObject>>
PersonVO
+id : Long
+tag : String

throws a "cannot find symbol : method getId() ... cannot find symbol : method getTag()"
in class PersonDaoBase :
 public void toPersonVO(Person source, PersonVO target)
 ...
        target.setId(source.getId());
        target.setTag(source.getTag());
}

these field are in fact generated inside PersonPK, so code should be like this :


 public void toPersonVO(Person source, PersonVO target)
 ...
        target.setId(source.getPk().getId());
        target.setTag(source.getPk().getTag());
}

This forum topic is about the same problem: http://galaxy.andromda.org/forum/viewtopic.php?t=4937

 All   Comments   Change History      Sort Order:
Comment by Vance Karimi [04/Dec/07 03:10 PM]
Fix applied in cvs.

Comment by Timo Reichert [15/Feb/08 09:08 AM]
Looks as if there is now a new bug.
For each property, there is a converter method creates as

target.setXyz(source.getPk().getXyz());

Regardless of whether the property is a identifier or not!

Take the example above:

<<Entity>>
Person
<<Identifier>> +id : Long
<<Identifier>> +tag : String
+name : String

      ||
      V

<<ValueObject>>
PersonVO
+id : Long
+tag : String
+name : String

the cartridge generate the following method:
public void toPersonVO(Person source, PersonVO target)
 ...
        target.setId(source.getPk().getId()); //OK!
        target.setTag(source.getPk().getTag()); //OK!
        target.setName(source.getPk().getName()); //FALSE!
}