Hibernate + Spring : Strange Behavior

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,

Kranthi

[2326 byte] By [Aurora_Greena] at [2007-11-27 10:15:07]
# 1

Re #1, keep in mind that Hibernate will delay doing updates as much as possible. Updates are queued and run at the close of the transaction. So if you have an update earlier in the session you won't see Hibernate act on it until the end.

RaymondDeCampoa at 2007-7-28 15:37:35 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...