This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Hibernate 2 to Hibernate 3 migration Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply Bookmark "Hibernate 2 to Hibernate 3 migration" Watch "Hibernate 2 to Hibernate 3 migration" New topic
Author

Hibernate 2 to Hibernate 3 migration

John Molitor
Ranch Hand

Joined: Nov 08, 2004
Posts: 39
Any gotcha's, tips, or tricks?
Nick Heudecker
Ranch Hand

Joined: Jul 09, 2000
Posts: 52
When I migrated, I had some issues with the new query parser, so I configured Hibernate to use the classic parser.

Make sure you copy all of the new jars over, and run a sed script on your code tree (including config and properties files) to replace the package names.

I think that's all that tripped me up. The Hibernate 3 migration guide can be found here: http://www.hibernate.org/250.html


---<br />Co-author of "Hibernate Quickly"<br /><a href="http://www.manning.com/books/peak" target="_blank" rel="nofollow">http://www.manning.com/books/peak</a>
Patrick Peak
Greenhorn

Joined: Aug 23, 2005
Posts: 19
Also, if you are using Spring's HibernateTemplate (which I have done in some of my projects) you need to change their packages to use the new Hibernate 3 classes. The old Hibernate 2.1 is covered in

org.springframework.orm.hibernate

while the new stuff is in

org.springframework.orm.hibernate3

This means there are 2 HibernateTemplate classes

org.springframework.orm.hibernate.HibernateTemplate
org.springframework.orm.hibernate3.HibernateTemplate

So don't just blindly autoimport (in IDEA for example) without checking the packages first.


Hibernate Quickly - <a href="http://www.manning.com/books/peak" target="_blank" rel="nofollow">http://www.manning.com/books/peak</a>
Dave Salter
Ranch Hand

Joined: Jul 20, 2005
Posts: 292

I've migrated a fairly simple app from H2 to H3 and didn't really have any problems. The most difficult part was probably finding out exactly what jars to use.

Most of the books I have seen (Hibernate in Action in particular) only cover H2, however I found that the majority of it is atill applicable to H3.
John Molitor
Ranch Hand

Joined: Nov 08, 2004
Posts: 39
Thanks for the responses everyone.
Billy Tsai
Ranch Hand

Joined: May 23, 2003
Posts: 1297
so the hibernate 2 to 3 migration guide is suitable for any databases?


BEA 8.1 Certified Administrator, IBM Certified Solution Developer For XML 1.1 and Related Technologies, SCJP, SCWCD, SCBCD, SCDJWS, SCJD, SCEA,
Oracle Certified Master Java EE 5 Enterprise Architect
Jignesh Patel
Ranch Hand

Joined: Nov 03, 2001
Posts: 625

http://www.hibernate.org/250.html
http://www.hibernate.org/250.html#A23

Looks like 2.1 and 3.0 are not compatible
Dave Salter
Ranch Hand

Joined: Jul 20, 2005
Posts: 292

Hibernate 3 is not a "drop-in" replacement for Hibernate 2, so in that sense they are not compatible.

The migration guide mentioned above by Nick included details of how to convert from H2 to H3 though.

Depending upon what features you have used, you may find migration straightforward or a little more complex.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Hibernate 2 to Hibernate 3 migration
 
Similar Threads
[SCBCD 5.0] Simplified (reduced) SELECT clause form
how to cast String to Clob ?
WA #1.....word association
Where to put questions regarding Hybernet?
Good books or tutorial site for JDO