-->
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.  [ 3 posts ] 
Author Message
 Post subject: OpenSessionInView updating rows problem
PostPosted: Sun May 23, 2004 12:07 pm 
Beginner
Beginner

Joined: Tue Nov 18, 2003 10:16 am
Posts: 33
Location: Cluj-Napoca, Romania
I am using an Spring and hibernate architecture for my web application.
It seems that if using OpenSessionInView , at editing , the data is not updated into the table (at least is not comited).
The same code is working correct from the unittests.

my transaction proxy looks like this:

<bean id="userService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref local="transactionManager"/>
</property>
<property name="target">
<ref local="userServiceTarget"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>

Many thanks

Florin Marcus


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 23, 2004 12:21 pm 
Beginner
Beginner

Joined: Tue Nov 18, 2003 10:16 am
Posts: 33
Location: Cluj-Napoca, Romania
I think i better enter into more details with this problem:

I have a generic DAO implementation for Hibernate. For example, the save method looks like this:

Code:
    public void save(final Object object)
    {
        getHibernateTemplate().execute(new HibernateCallback()
        {
            public Object doInHibernate(Session session) throws HibernateException
            {
                session.saveOrUpdate(object);
                return null;
            }
        });
    }


if I am using session.flush after

Code:
session.saveOrUpdate(object)


everything is working fine (at least in this single case).
But I think flushing the session will give me more problems than it solves.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 24, 2004 8:50 am 
Senior
Senior

Joined: Wed Aug 27, 2003 6:04 am
Posts: 161
Location: Linz, Austria
Regarding flushing: OpenSessionInViewFilter/Interceptor assumes that it is used with middle tier transactions or HibernateTemplates with flushMode FLUSH_EAGER. If you use neither, there won't be any flush on such a Session. (The javadoc explicitly states this.)

In your particular case, double-check your configuration and your execution logs: Are those transactions really applied? Do you always work with the "userService" proxy, never with the target directly? At the end of a non-read-only transaction, a flush should happen - check the debug logs.

As a side note, are you aware that HibernateTemplate features a lot of convenience methods that pre-implement typical one-liners like saveOrUpdate? For example:

Code:
getHibernateTemplate().saveOrUpdate(object);


Juergen


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