I have using Spring2 + Hibernate3 + Xfire1.2.6. for two applications. 
When one app A calls a WS on the other app B, the service method runs without 
exceptions nor errors. 
However, when there are objects (models) that happens to be get from a dao 
hibernate AND somehow property value being modified in the service method (no 
matter the modification is done by calling a sub method or what), the result 
will be all objects with new values are saved to DB at the end of the day... 
but the coding does not contain any save method!

A test I wrote on app B:

Model Object-
/**
 * @struts.form include-all="true" extends="BaseForm"
 * @hibernate.class
 *         table="TBL_ATEST"
 *     
 */
public class Atest extends baseObject implements java.io.Serializable {
        private Long id;
        private String val1;

...getter and setter...

...override tostring(), equals(), hashcode() 
}



Dao hibernate-
public class xxxDaoHibernate extends BaseDaoHibernate implements xxxDao {
...
    public Atest getAtest(final Long id) {
        Atest atest = (Atest) getHibernateTemplate().get(Atest.class, id);
        if (atest == null) {
            log.warn("uh oh, atest with id '" + id + "' not found...");
            throw new ObjectRetrievalFailureException(Atest.class, id);
        }
        return atest;
    }
...
}



Service Method-
/**
* 
* Tell xfire, which objects it will find in the List
* @aegis.method
* @aegis.method-return-type componentType="java.lang.String"
*/
public String atestService(...something...) {
        Atest a = dao.getAtest(new Long("1"));
        a.setVal1("222");
        return "S";
}



Service XML-
    <bean name="ekaService" class="org.codehaus.xfire.spring.ServiceBean">
        <property name="serviceBean" ref="mdmsptylinkManager"/>
        <property name="serviceClass" value="com.eg.tsi.service.EkaWebService"/>
        <property name="inHandlers">
            <list>
                <ref bean="addressingHandler"/>
            </list>
        </property>
    </bean>

    <bean id="addressingHandler" 
class="org.codehaus.xfire.addressing.AddressingInHandler"/>



I have a DB table with the record id=1, val1='111'. As you can guess, after 
invoking the service from app A, everything process as expected except now val2 
becomes "222".
A work around on this problem is to create a differnet instant of the same 
object, and clone all values to from the 'old' dao hibernate get object to 
the 'new' object such that all object manipulations will be done on the 'new' 
object.
And yes, the 'old' object won't be saved if nothing change on it in this case.

I already have an up and running business application using the work around 
which is working fine. However, this strange problem should better be solved in 
the long run.

Any idea on this? is this a transaction handling problem? or xfire/hibernate 
configuration issues?


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net
For additional commands, e-mail: users-h...@appfuse.dev.java.net

Reply via email to