Hi,
I encountered a small problem with code generation for an association class:
I have a relationship between LibelleMultiLingue and Langue, naviguable from LibelleMultiLingue to Langue, with an association class. In LibelleMultiLingue, VP generates the following method:
public Traduction getTraductionByLangue(Langue aLangue) {
Traduction[] lTraductions = traductions.toArray();
for(int i = 0; i < lTraductions.length; i++) {
if(lTraductions[i].getLangue().equals(aLangue)) {
return lTraductions[i];
}
}
return null;
}
This cannot work as is, since equals is not redefined in class Langue. This is of course trivial to solve like this:
public boolean equals (Object o) {
if (o == this)
return true;
if (o instanceof Langue)
return (Langue)o.getBusinessKey () == this.getBusinessKey ();
} else
return false;
}
but I think it should be automatically generated, wouldn’t it ? Of course, the user should be able to choose the business key.
For the same diagram, I’d like to be able to specify that the relationship is mapped to a Map, indexed by one of the existing fields of the target class of the association (“businessKey” in class “Langue” in my sample). Is this possible ? I didn’t find any way to do that. Choosing “Map” for the association in “ORM/Collection type” produces a Map indexed by an auto-generated field in the target class.
Anyway, SDE is a great, great product !
Thanks in advance for any remark,
JM