Hibernate is an excellent ORM package. It eliminates all SQL/ data access code from a java project. But it introduces a problem if not care is taken in designing.
In one of my projects, we modeled a very deep tree of objects and if required with one single query we could load the entire database. This is dangerous and has big performance hits.
The approach for the next project would be.
1. Use Hibernate and keep data integrity with constrains.
2. Have a DAO to control every 3 or 4 model objects. each dao will manage a coarse grained object.
3. Hibernate cannot fetch a deep tree object because the objects will be disconnected at hibernate level.
4. for querying 'private fields' will be used. in the hibernate hbm.xml files the relationships for queries will be done using 'field' accessor. That means still querying is possible, but no deep fetching or lazy initializing exceptions which can happen due to getters in closed session.
Blog Archive
Search This Blog
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment