Tag Archives: hibernate

Javapolis 2006 Presentations

Javapolis has become one of the major Java events in Europe, combining in one place and one week the latest trends in different kinds of presentations. Last year’s edition took place in December and now the videos of several presentations, hopefully all of them in the near future, are being released online, something really neat for people like me that couldn’t be there:

Javapolis 2006 Presentations

There’s more content, such as presentation slides in pdf, available at Javapolis homepage (requires fres registration).

Don’t Let Hibernate Steal Your Identity

This was my first real issue with Hibernate when working, right after trying to understand how mapping files work and all the other "hey… if put this here what happens if I put this here".

The problem is simple, the default behaviour of the equals method doesn’t fit in a what you would need for an Hibernate object: it’s relies on the internal hash code generated for each instance, so it will not distinguish between two different instances that represent the same row in the database. The immediate solution is obvious, override equals and hashCode methods so we can, at least, compare the id’s of the objects to check whether they represent the same database entity, but this raises another problem: when an object hasn’t been saved in the database (the id field is still null) there’s no way to compare it to another one.

It’s becoming clear that problem is gets more complicated each time we look at it, but James Brundege came to the rescue and released a fine article where he takes this issue one step beyond, or even two.

ONJava.com: Don’t Let Hibernate Steal Your Identity

 

Technorati Tags: java, hibernate, orm, o/r mapping, database

Switch to our mobile site