[
http://opensource.atlassian.com/projects/hibernate/browse/HBX-626?page=all ]
Max Rydahl Andersen closed HBX-626:
-----------------------------------
Resolution: Rejected
i follow the idea, but encouraging alot of static methods for implementing a equals is not
something i'm keen on.
rejecting until a better suggestion (and patch) becomes available.
p.s. its trivial to implement this specific wanted behavior via customizing the
templates.
New meta tag for specifying the class that implements equals
algorithm
----------------------------------------------------------------------
Key: HBX-626
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HBX-626
Project: Hibernate Tools
Type: Improvement
Components: hbm2java
Versions: 3.1beta4
Reporter: David Leal
Just to suggest a usefull new meta tag in order to specify the way to implement the equal
algorithm. Now the meta tags allow to specify which property will be considered on the
equals method, but what about if I have a comlex algorithm for determine if two object are
equals or not.
The solution for the moment is to extend the generated domain class an override the
equals method, another ugly solution would be modify the generated java class, which
generate problems in order to mantain the code.
My suggestion will be a meta attribute on the class node in order to define the which
class will implement the equals method, for example:
<class name="a.b.c.domain.Sample" table="sample">
<meta
attribute="equal-class">a.b.c.domain.SampleEquals</meta>
</class>
so the generated class will be:
public boolean equals(Object other) {
return SampleEquals.isEquals(this, other);
}
where SampleEquals should be an utility class with a single static method: isEquals.
Otherwise a more professional solution could be a regular class that should implement a
given interface for implementing the equals algorithm.
Now on the SampleEquals.isEquals method, your are free to implement a very complicated
algorithm about how to make a desition if to objects are equals or not.
Thanks in advance,
David
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira