Hibernate version:
3.2.5ga
Code between sessionFactory.openSession() and session.close():
Wired through Spring
Name and version of the database you are using:
Sybase 12
Hello All,
In our application we have 100's of queries, each of which have joins spanning 4 to 5 tables. Once we retrieve the result we process it and pass them to the User layer where they are used in the UI.
We want to reduce the data transfer between our app and the browser as we have clients spread across the globe and data transfer latency is now becoming a significant issue in performance. For e.g. Users in NA don't complain about performance but users in EU and Asia Pac do compare about performance.
When Hibernate fetches entities, it fetches each and every attribute defined in the HBM for the parent object and its child collections. However, on the UI only 30 to 40% fields are actually referred to. Rest of the attributes travel right up to the browser, which is not really necessary. Please note that we do use these attributes in HQL queries while apecifying conditions, etc. So, we can't really remove these off the HBM.
One approach we can take is to always do Query.setReadonly(true) and set nulls to the attributes we do not need on the UI side. However, this would need a heavy code change, coz' we'll need to modify the result of each and every query and there are 100's of them. So, this approach does not sound too good to me.
Another approach I'm thinking is to setReadOnly(true) and apply an interceptor which will set all the audit fields and other unneeded fields to null. The question I have is - which exact method out of
getEntity
instantiate
onLoad
onPrepareStatement
of the Interceptor interface would be the right one to write the code snippet where the individual fields can be set to null.
Can anybody comment on this approach and answer this question please?
_________________ Harshal Vaidya
|