-->
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 Session Cache Understanding ? : with OSIV
PostPosted: Mon Aug 16, 2010 10:04 am 
Newbie

Joined: Mon Aug 16, 2010 9:46 am
Posts: 1
Deal All,

Hope you all doing good. We have specific hibernate session problem when new objects are not fetched b/w HSQL calls.
Please help and find the code / configuration below.

Controller_method()
{
Parent p1 = findObjectsWithParent_method1();
Parent p2 = findObjectsWithParent_mothod2();
}

Parent Class
============
Parent
{

//one-to-many hibernate
Set<Child1> childs1;
Set<Child2> childs2;
}

Child1 { Date fromDate; }
Child2 { Date fromDate; }

Service Methdods
================
findObjectsWithParent_method1()
{
return dao.findObjectsWithParent_method1(new Date());
}
findObjectsWithParent_method2
{
return dao.findObjectsWithParent_method2();
}

Database Rows count for Parent
Parent1 = count 1
Child1 for Parent1 = 3
Child2 for Parent1 = 4

DAO Methods
============
findObjectsWithParent_method1(Date date)
{
return getHibernateTemplate().find("from Parent p left join fecth childs1 ch where p.ch.fromDate = ?", new Object[]{date});
//returns parent with 2 child1 matching date condition
//expected works - GREAT
}
findObjectsWithParent_method2(Date date)
{
return getHibernateTemplate().find("from Parent p left join fecth childs1 ch left join fetch childs2);
//returns parent with 2 child1 and 4 child2
//NOT Expected - since I did not mention any where clause for childs1 , I Should get all childs1
//expected : parent with 3 childs1 and 4 childs2
}
Hope it is clear in code implementation

**Configurations:-
================
Session factory (hibenate)
-----------------------------
<prop key="hibernate.autocommit">false</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>

Spring Trasaction Manager
----------------------------
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>

DAO Implementations
-------------------
<bean id="dao" class="com.merrill.mss.dao.hibernate.DaoHibernate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>

Transaction Attributes
-----------------------
<bean id="txProxyTemplate" abstract="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager"><ref bean="transactionManager"/></property>
<property name="transactionAttributes">
<props>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="remove*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="merge*">PROPAGATION_REQUIRED</prop>
<prop key="cal*">PROPAGATION_REQUIRED</prop>
<prop key="exec*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="undo*">PROPAGATION_REQUIRED</prop>
<prop key="make*">PROPAGATION_REQUIRED</prop>
<prop key="nextPayDate*">PROPAGATION_NOT_SUPPORTED</prop>
<prop key="redemption*">PROPAGATION_NOT_SUPPORTED</prop>
<prop key="batchJobredemption*">PROPAGATION_REQUIRES_NEW</prop>
<prop key="changeTrustStatus*">PROPAGATION_NOT_SUPPORTED</prop>
<prop key="port*">PROPAGATION_REQUIRES_NEW</prop>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>

Service Implementations
---------------------------
<bean id="service" parent="txProxyTemplate">
<property name="target">
<bean class="com.merrill.mss.service.impl.ServiceImpl">
<property name="dao"><ref bean="dao"/></property>
</bean>
</property>
</bean>

**Versions :-
================
Spring 3.0.3
Hibernate 3.2.6.ga

Problem:-
findObjectsWithParent_method1() and findObjectsWithParent_method2() is NOT behaving as expected. findObjectsWithParent_method1() is querying database and
got Parent with 2 childs1 matching the date condition provided in HSQL. But findObjectsWithParent_method2() returns Parent with incorrect number of childs1.

I assume that after findObjectsWithParent_method1(), then transaction manager is not clearing the session cache.

I have tried to disable query cache , it did not help. If I remove OSIV , this functions works well as expected. I can't remove OSIV, since other pages breaks (bcoz of lazy).

Any thoughts?.. We are in kind of dead road.


Thank you
Karthick


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.