-->
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.  [ 2 posts ] 
Author Message
 Post subject: Result getting cached; second level cache is off
PostPosted: Wed Mar 01, 2006 3:56 pm 
Newbie

Joined: Fri Feb 10, 2006 7:19 pm
Posts: 6
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.0

Mapping documents:
<hibernate-mapping>
<class name="com.serena.dashboard.security.users.DashboardUser" table="SECURITY_PRINCIPAL">
<id name="id" column="PRINCIPAL_ID" />
<property name="userName" column="FULL_PATH" />
<property name="role"
formula="( select sp.FULL_PATH from SECURITY_PRINCIPAL sp where sp.PRINCIPAL_ID = (select sur.ROLE_ID from SECURITY_USER_ROLE sur where sur.USER_ID = PRINCIPAL_ID) )"/>
<property name="fullName"
formula="( select ppv.PROPERTY_VALUE from PREFS_PROPERTY_VALUE ppv where ppv.PROPERTY_NAME='user.name.full' and ppv.NODE_ID = (select pn.NODE_ID from PREFS_NODE pn where pn.NODE_NAME='userinfo' and pn.FULL_PATH = CONCAT(FULL_PATH, '/userinfo') ) )"/>

</class>
</hibernate-mapping>



Code between sessionFactory.openSession() and session.close():
---------------------- UserManager Java class -----------------------------
Session hiberSession = null;
hiberSession = JetspeedHibernateUtil.getSession();
hiberSession.beginTransaction();


String hqlStatement = "from DashboardUser user where user.userName like ? and user.role like ? and user.fullName like ? ";
List result = null;

try {
Query query = hiberSession.createQuery(hqlStatement);
query.setString(0, "/user/" + searchCriteria.getUserName() );
query.setString(1, "/role/" + searchCriteria.getRole() );
query.setString(2, searchCriteria.getUserFullName());
result = query.list();
}
catch( Throwable t ){
t.printStackTrace();
}

-------------------- JSP displaying user list has commitTransaction -------------
<%com.serena.dashboard.hibernate.JetspeedHibernateUtil.commitTransaction();%>
<%com.serena.dashboard.hibernate.JetspeedHibernateUtil.closeSession();%>

Full stack trace of any exception that occurs: NA

Name and version of the database you are using: Oracle 9i

The generated SQL (show_sql=true):
Hibernate: select dashboardu0_.PRINCIPAL_ID as PRINCIPAL1_5_, dashboardu0_.FULL_
PATH as FULL2_5_, ( select sp.FULL_PATH from SECURITY_PRINCIPAL sp where sp.PRIN
CIPAL_ID = (select sur.ROLE_ID from SECURITY_USER_ROLE sur where sur.USER_ID = d
ashboardu0_.PRINCIPAL_ID) ) as formula0_, ( select ppv.PROPERTY_VALUE from PREFS
_PROPERTY_VALUE ppv where ppv.PROPERTY_NAME='user.name.full' and ppv.NODE_ID = (
select pn.NODE_ID from PREFS_NODE pn where pn.NODE_NAME='userinfo' and pn.FULL_P
ATH = CONCAT(dashboardu0_.FULL_PATH, '/userinfo') ) ) as formula1_ from SECURITY
_PRINCIPAL dashboardu0_ where (dashboardu0_.FULL_PATH like ?) and (( select sp.F
ULL_PATH from SECURITY_PRINCIPAL sp where sp.PRINCIPAL_ID = (select sur.ROLE_ID
from SECURITY_USER_ROLE sur where sur.USER_ID = dashboardu0_.PRINCIPAL_ID) ) lik
e ?) and (( select ppv.PROPERTY_VALUE from PREFS_PROPERTY_VALUE ppv where ppv.PR
OPERTY_NAME='user.name.full' and ppv.NODE_ID = (select pn.NODE_ID from PREFS_NOD
E pn where pn.NODE_NAME='userinfo' and pn.FULL_PATH = CONCAT(dashboardu0_.FULL_P
ATH, '/userinfo') ) ) like ?)
Debug level Hibernate log excerpt:


------------------------------------------------------------------------------------
I am using hibernate to search Jetspeed users based on username, his full name and assigned role. Since Jetspeed does not have wildcard search yet, we decided to go against the database directly using hibernate. The updates to Jetspeed users happen through Jetspeed's own User and Role managers. Thus there are two separate applications updating same database. When I change role for a particular user using Jetspeed RoleManager, it gets updated properly in the database but hibernate still returns old role value for that user unless I restart Tomcat.

I have disabled second level caching using
<property name="hibernate.cache.use_second_level_cache">false</property>

Sorry for the big post but wanted to include as much information as possible.

Thanks.
Meghana


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 01, 2006 4:11 pm 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
the only other caching is in the "Session" object (mandatory, can't turn off) - make sure there are no handles to the session that are saved between web-requests.

_________________
-JT

If you find my replies helpful, please rate by clicking 'Y' on them. I appreciate it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.