-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Performance and Interceptor related question
PostPosted: Fri Jan 02, 2009 11:49 am 
Newbie

Joined: Wed Jan 23, 2008 7:45 am
Posts: 14
Location: Pune,India
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 02, 2009 4:46 pm 
Red Hat Associate
Red Hat Associate

Joined: Mon Aug 16, 2004 11:14 am
Posts: 253
Location: Raleigh, NC
There's a big difference between moving data between:

1. the database and the app/webserver
2. the app/webserver and the client

The tactics you mention address #1 but the symptoms you complain of point to #2. If data transfer is really the issue for you, then there's not much you can do with Hibernate to fix it; you need to create smaller/lighter HTML pages.

OTOH, if it really is Hibernate that is the problem, then consider normalizing your data a bit more, perhaps employ some caching. You can also select only certain columns by specifying them by name - note that this returns tuples rather than actual entity instances. These queries look something likie:

Select c.id, c.name from Cat c

And you get back a List containing Object[] where each item in the array is one of the returned properties.

_________________
Chris Bredesen
Senior Software Maintenance Engineer, JBoss


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 07, 2009 2:55 pm 
Expert
Expert

Joined: Sat Jan 17, 2004 2:57 pm
Posts: 329
Location: In the basement in my underwear
If you're using proxies you can actually enable lazy loading at the property level. IIRC, it was a bit to get my head wrapped around initially but if the property isn't touched by the time the session is closed then the value is either NULL or a proxy (in the case of a many to one).

It would still probably be a bit of a coding change as you would need to ensure that anything you wanted to render on the UI was 'touched' in the DB access layer.

Take a look at the reference docs and see if it'll do the trick for you, like I said, it was a bit a head scratcher at first but I was able to work it out.

_________________
Some people are like Slinkies - not really good for anything, but you still can't help but smile when you see one tumble down the stairs.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.