By lincolnthree
via ocpsoft.com
Published: Aug 18 2008 / 03:05
Tired of wiring in an id, version, and timestamp field into all of your Hibernate objects? There’s an easy way to solve this pain once and for all of your classes. Avoid code-repetition: today’s article focuses on using Hibernate Annotations to map common fields into one mapped superclass.
Comments
cherouvim replied ago:
bad advice.
see http://www.hibernate.org/109.html for proper hashcode and equals.
kupolov replied ago:
The recomendation of using the properties of an object rather then
the object identity and or synthetic primary key is just as broken as
the problem we are trying to highlight and solve.
See http://www.hibernate.org/109.421.html for more details.
lincolnthree replied ago:
This tutorial does not recommend that properties of the object be used in the object's identity; however, it does demonstrate that you can choose to implement at least partial behavior for these methods in the super class so that comparing object id fields can be done with the super.equals() or super.hashcode() methods instead of redefining this behavior in each mapped object class.
Please feel free to post your suggested changes.,
lincolnthree replied ago:
I forgot to mention. Really please post your suggestions, I'm interested to see how I can improve what is there now. I've read the discussions on equals and hashcode, but it's possible I've made a mistake?
Voters For This Link (6)
Voters Against This Link (2)