-->
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.  [ 6 posts ] 
Author Message
 Post subject: Hibernate + Spring : Strange Behavior
PostPosted: Mon Jul 09, 2007 2:12 pm 
Newbie

Joined: Tue Jul 03, 2007 11:09 am
Posts: 14
Hi,

I am using a method in DAO which is of the following format:

public getAllCategories(){
return getHibernateTemplate().find(" from CategoryMaster ");
}

and it is returning a list of POJOs to the serviceClass that called this method. Till here its fine.


Spring Mapping:
-------------------
THe DAO is enclosed in transactionManager in Spring Application-context.xml as follows:

<bean name="abstractSimpleWrite" lazy-init="true"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="hibernateTrMgr" />
</property>
<property name="transactionAttributeSource">
<bean
class="org.springframework.transaction.interceptor.MatchAlwaysTransactionAttributeSource">
<property name="transactionAttribute">
<ref bean="simpleWriteTrAttr" />
</property>
</bean>
</property>
</bean>
<bean id="simpleWriteTrAttr"
class="org.springframework.transaction.interceptor.DefaultTransactionAttribute">
<property name="propagationBehaviorName">
<value>PROPAGATION_REQUIRED</value>
</property>
<property name="isolationLevelName">
<value>ISOLATION_DEFAULT</value>
</property>
</bean>


The Strange Behavior-1:
------------------------------
When i run the application i get batch-update exception. But the point is that i haven't called any update methods then how is update being called (Also, i get update queries being printedd on the console. When debugging i found that just before the transaction ends or just before the service calass ends the updates are being called and i get batch exception.)


Strange Behavior-2:
------------------------
And supposing that i call this method of DAO: findByExample("flagActive","Y"); i get the array list delivered from the service class also with out the update being called at all.

If i called the method: findByExample('flagActive','Y'); and in the same Service Method i call findByExample('flagActive','N'); Again to the end of the service layer just before the taransaction commits i get batch update exception.

Please help me ASAP.

regards,
ravi c


Top
 Profile  
 
 Post subject: Bad Equals
PostPosted: Mon Jul 09, 2007 4:06 pm 
Newbie

Joined: Fri Apr 07, 2006 11:29 am
Posts: 17
It is likely that the equals method on your POJOs is invalid. Please post the equals code. Hibernate uses the equals in its dirty check. If the equals is not written properly, hibernate will see the object as dirty when flushing and the update will occur.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 10, 2007 1:55 am 
Newbie

Joined: Tue Jul 10, 2007 1:50 am
Posts: 4
Hi,

We didn't override equals() method but we tried in the following way:

Code:
public boolean equals(Object obj)
  {
SaPostingCategoryMaster cat = (SaPostingCategoryMaster)obj;      
if(this.getPostingCategoryPk().equals(cat.getPostingCategoryPk()))
   return true;
    else
    return false;
   }


Still the same problem persists..

Plz do help ..

Regards,
Kranthi Kiran


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 10, 2007 9:17 am 
Newbie

Joined: Tue Sep 19, 2006 6:47 am
Posts: 15
Can you spot any modifications by the update statement in the logs?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 11, 2007 3:12 am 
Newbie

Joined: Tue Jul 10, 2007 1:50 am
Posts: 4
We are getting BatchUpdate exceptions and update is being called 6-7 times...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 24, 2007 6:00 am 
Newbie

Joined: Tue Jul 03, 2007 11:09 am
Posts: 14
hi,

any help??? or pointers???


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