Link Details

Link 104462 thumbnail
User 319676 avatar

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.
  • 6
  • 2
  • 1194
  • 428

Comments

Add your comment
User 321721 avatar

cherouvim replied ago:

-1 votes Vote down Vote up Reply

bad advice.
see http://www.hibernate.org/109.html for proper hashcode and equals.

User 135274 avatar

kupolov replied ago:

1 votes Vote down Vote up Reply

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.

User 319676 avatar

lincolnthree replied ago:

-1 votes Vote down Vote up Reply

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.,

User 319676 avatar

lincolnthree replied ago:

0 votes Vote down Vote up Reply

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?

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Voters For This Link (6)



Voters Against This Link (2)