-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate Second Level Cache to increase perfomance
PostPosted: Tue May 08, 2007 1:34 pm 
Beginner
Beginner

Joined: Tue May 08, 2007 1:20 pm
Posts: 24
I have a h:selectOneMenu dropdown which performs CRUD operation.
The dropdown list has a value "New" which allows the users to enter new values into other form fields thereby performing Create/Insert operation
When users pick other values from the dropdown list it dynamically populates other fields in the form thereby facilitating Update/Delete operation. The problem is whenever i pick a different value from the dropdown list the database call happens twice.
Here is the dropdown
Code:

<h:selectOneMenu id="manufList" value="#{manufacturerBean.selectedManufacturer}" >
<f:selectItem itemLabel="New" itemValue="New" />
<f:selectItems value="#{manufacturerBean.manufacturerList}" />
<a4j:support action="#{manufacturerBean.loadManufacturerDetails}" event="onchange" reRender="manufName,manufDescription,manufSource,btnSave,btnDelete" />
</h:selectOneMenu>
</h:panelGrid>


Here is the sequence of method calls whenever i pick a value from the dropdown list
- First time the method in f:selectItems gets called which results in a database call
- Second time as expected Ajax4JSF onchange event method gets called
- Third time again the method in f:selectItems gets called resulting in database call

Here are the snippets from log file which substantiates that whenever i pick a value from dropdown database call occurs twice
Code:

********** FIRST METHOD CALL ***************************
2007-05-07 16:46:46,002 INFO [com.boeing.nmt.nams.view.bean.ManufacturerBean] - < *** In getManufacturerList Backing Bean*** >
2007-05-07 16:46:46,002 INFO [com.boeing.nmt.nams.service.impl.ManufacturerManagerImpl] - < *** In getManufacturerList Spring*** >
Hibernate: select namsmanufa0_.ID as ID60_, namsmanufa0_.CHANGE_USER as CHANGE2_60_, namsmanufa0_.NA
ME as NAME60_, namsmanufa0_.DESCRIPTION as DESCRIPT4_60_, namsmanufa0_.SOURCE as SOURCE60_, namsmanu
fa0_.STATUS as STATUS60_, namsmanufa0_.CHANGE_DATE as CHANGE7_60_ from NAMS_MANUFACTURER namsmanufa0
_

********** SECOND METHOD CALL ***************************
2007-05-07 16:46:46,237 INFO [com.boeing.nmt.nams.view.bean.ManufacturerBean] - < *** In loadManufacturerDetails method *** >
Hibernate: select namsmanufa0_.ID as ID60_0_, namsmanufa0_.CHANGE_USER as CHANGE2_60_0_, namsmanufa0
_.NAME as NAME60_0_, namsmanufa0_.DESCRIPTION as DESCRIPT4_60_0_, namsmanufa0_.SOURCE as SOURCE60_0_
, namsmanufa0_.STATUS as STATUS60_0_, namsmanufa0_.CHANGE_DATE as CHANGE7_60_0_ from NAMS_MANUFACTUR
ER namsmanufa0_ where namsmanufa0_.ID=?

********** THIRD METHOD CALL ***************************
2007-05-07 16:46:46,565 INFO [com.boeing.nmt.nams.view.bean.ManufacturerBean] - < *** In getManufacturerList Backing Bean*** >
2007-05-07 16:46:46,565 INFO [com.boeing.nmt.nams.service.impl.ManufacturerManagerImpl] - < *** In getManufacturerList Spring*** >
Hibernate: select namsmanufa0_.ID as ID60_, namsmanufa0_.CHANGE_USER as CHANGE2_60_, namsmanufa0_.NA
ME as NAME60_, namsmanufa0_.DESCRIPTION as DESCRIPT4_60_, namsmanufa0_.SOURCE as SOURCE60_, namsmanu
fa0_.STATUS as STATUS60_, namsmanufa0_.CHANGE_DATE as CHANGE7_60_ from NAMS_MANUFACTURER namsmanufa0

Note : I have managed bean in session scope
I have posted this on JSF/MyFaces forums people suggested me to use Hibernate Second Level Cache or Query Cache to avoid unnecessary database calls. As i am newbie to Hibernate any pointers/suggestions with snippet code will be highly appreciated

Regards
Bansi


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

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.