-->
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.  [ 4 posts ] 
Author Message
 Post subject: Hibernate + Spring + select statement : Update Exception
PostPosted: Mon Jul 09, 2007 2:13 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:
PostPosted: Tue Jul 10, 2007 9:41 am 
Beginner
Beginner

Joined: Fri Apr 15, 2005 3:30 pm
Posts: 46
Location: Fortaleza, Brazil
Why are you using an interceptor? Have you placed hibernate / spring in DEBUG mode to see what's causing the flush? Also, format your mappings / code / logs via as its difficult to read what you posted.

Try posting the _formatted_ stacktrace, DEBUG, and hibernateTrMgr bean and maybe we can help.

Robert


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 13, 2007 12:47 am 
Newbie

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

How do we place the hibernate or spring in debug mode? any help??? We get the sql statements printed off when they fire and we see that -during debuggin, when the transaction is being ended update statements are being fired and we get batch update exception. The exception says unable to update null values into the column (its an auto generated primary key) and fails.

why should the update fire at all when i am doing is selection?? any pointers would be appreciated (or the chapter names in the book java***hibernate)

The interceptors that you see in the xml file are to handle transactions.


you may want to see the forum: http://forum.hibernate.org/viewtopic.ph ... 45#2358445

the xml is formatted for easier understanding:



<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>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 16, 2007 1:48 am 
Newbie

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

Any help is appreciated..!!

~Kranthi


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