Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Best practices in using Hibernate

 
Swami nathan
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Cameron

Kindly share some of the best practices while using Hibernate. Does your book share some tips on them?

Thank you.
[ June 02, 2008: Message edited by: Swami nathan ]
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the biggest best practice is really understanding how Hibernate works, and not just 'how to do things with Hibernate.'

My book certainly discusses practices such as Open Session in Viewand how to efficiently cache the the SessionFactory object in a singleton. I discuss how to build DAO objects that have Hibernate as the persistence mechanism, and the book also demonstrates how to leverage the J2EE service pattern, but all in all, I always belive that the most fundamental best practice is understanding how Hibernate works.

When people don't really understand what's going on with Hibernate, you often see people making too many unneeded calls to save, or performing flushes or refreshes when they aren't necessary. These types of extremely common mistakes aren't really a product of not using a best practice, as much as a fundamental lack of understanding about how Hibernate works.

I do believe that this is one of the most important contributions my new Hibernate book brings to the market. Using very simple and easy to understand Hiberante tutorials, you not only learn how to use Hiberante, but you learn how it works. And having this very fundamental understanding will eliminate all of those pesky NonUniqueObjectExceptions and LazyInitializationExceptions that are the bane of Hibernate programmers. Furthermore, when those types of problems do arise, when you really understand Hibernate, you'll know how to fix them!

Kindest regards,

-Cameron McKenzie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic