[
http://galaxy.andromda.org:8080/jira/browse/HIB-78?page=comments#action_11236 ]
Wouter Zoons commented on HIB-78:
---------------------------------
did you experience this at runtime, or did you assume this from reading the
code ?
the way I understand it two entities without identifiers are equals only if
they are equal in the JVM
I'm wondering because you talk about entities without identifiers and yet you
pasted a fragment of velocity code that is only executed when there *are*
identifiers
this is what what is executed:
public boolean equals(Object object)
{
#if ($identifiers.empty)
return super.equals(object);
#else
if (this == object)
{
return true;
}
if (!(object instanceof $entity.entityName))
{
return false;
}
see what happens when there are no identifiers, is there something I am missing
?
> Two entities that have no identifier cannot be assumed to be equal
> ------------------------------------------------------------------
>
> Key: HIB-78
> URL: http://galaxy.andromda.org:8080/jira/browse/HIB-78
> Project: Hibernate Cartridge
> Type: Bug
> Versions: 3.0RC1
> Reporter: Michal Bielecki
> Assignee: Chad Brandon
>
> Two entities that have no identifier cannot be assumed to be equal!!!!!!
> Currently the following code will add just one Child: (assuming you have
> cascade save)
> Parent p1 = new Parent("P1");
> Child c1 = new Child("C1");
> Child c2 = new Child("C1");
> //Both c1 and c2 have no identifier
> p1.getChildren().add(c1);
> p1.getChildren().add(c2);
> //(p1.getChildren().size == 1) is true as c1.equals(c2)
> session.save(p1); //only one child saved
> In the body of equals method there is:
> #else
> if (this.$identifier.name == null ? that.$identifier.name != null :
> !this.${identifier.name}.equals(that.$identifier.name))
> {
> return false;
> }
> #end
> #end
> return true;
> #end
> there should be:
> #else
> if (this.$identifier.name == null || that.$identifier.name == null ||
> !this.${identifier.name}.equals(that.$identifier.name))
> {
> return false;
> }
> #end
> #end
> return true;
> #end
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://galaxy.andromda.org:8080/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
-------------------------------------------------------
This SF.net email is sponsored by: 2005 Windows Mobile Application Contest
Submit applications for Windows Mobile(tm)-based Pocket PCs or Smartphones
for the chance to win $25,000 and application distribution. Enter today at
http://ads.osdn.com/?ad_id=6882&alloc_id=15148&op=click
_______________________________________________
Andromda-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/andromda-devel