Prev Next

Hibernate / Hibernate Interview Questions III

Mention some of the Hibernate Best Practices.

  • Identify natural keys for all entities, and map them.
  • Place each class mapping in its own file.
  • Externalize query strings to make applications more portable.
  • Use bind variables to prevent SQL Injection.
  • Use hand-coded JDBC sparing: Using SQL defeats the entire purpose of using Hibernate. So, use it sparingly, only when it is performance-critical.
  • Prefer lazy fetching for associations. Explicitly disable eager fetching using lazy="false". When join fetching is appropriate to a particular use case, use a query with a left join fetch.
  • Use bidirectional associations: In a large application, almost all associations must be navigable in both directions in queries.

More Related questions...

Show more question and Answers...


Comments & Discussions