views:

400

answers:

6

Following the theme of other threads.

What are your most favorites tricks or techniques involving Hibernate?

My favorite is binding non-Hibernate generated classes to existing classes with additional functionality (i.e. summarization).

+1  A: 

Lazy Loading can be of great help if used properly!

renegadeMind
Got my vote... follows good programming practices and enhances performance
monksy
A: 

Using appropriate caching strategy performance can be improved.

sacsha
Could you expand on this? Its not very clear.
monksy
A: 

I almost always generate my classes from the HBM files and to get my domain objects with property change listeners I have made my own FreeMarker templates that adds property change support.

willcodejavaforfood
A: 

Please-please read Hibernate In Action. Although it's about Java version, it will give you a solid knowledge of what as ORM is all about, what problem it solves, where it's appropriate and where's not.

And, in line with previously said, evaluate if NHibernate is the best tool for the job.

Anton Gogolev
I don't think this answer follows the question asked. The question already assumes the user really likes using Hibernate.
monksy
+3  A: 

Second level caching. It dramatically improve the performance of the application for data that does not change (constant for example), while maintaining database integrity: you don't store constants as string in a column, but in a separate table bound by foreign key.

Additionnally, the second level caching can be shared across multiple web server!

Thierry-Dimitri Roy
+1  A: 

Editing hibernate configuration programmatically :) The dom4j entity mode.

Miguel Ping