So Spring is configured to automagically create and handle transactions for your managers with the following code in appfuse's applicationContext-service.xml:

    <aop:config>
        ...
<aop:advisor id="managerTx" advice-ref="txAdvice" pointcut="execution(* *..service.*Manager.*(..))" order="2"/>
    </aop:config>

    <tx:advice id="txAdvice">
        <tx:attributes>
        ...
            <tx:method name="*"/>
        </tx:attributes>
    </tx:advice>


So if the "thing" your action uses to update the model is in a package with service in it and the class has the name Manager in it then all method calls will be wrapped up in a transaction. If your "thing" does not match this then no transaction for you and you get the Read- Only mode.


So if you wanted to call the DAO directly from your action or you have some other convention for class naming then you can annotate your methods with @Transactional, thanks to the following code. Also from applicaitonContext-service.xml:

    <!-- Enable @Transactional support -->
    <tx:annotation-driven/>

-D
On May 15, 2008, at 3:09 PM, Doug Pham wrote:

Hi All,
My problem with the spring manage hibernate session continues. I have a struts 2 action with multiple method. My first call to the action display the information of my item which renders the information to a form. Once the user has edited or updated the form, it gets submitted and calls the same strtuts 2 action with a different method of course. At this point, I then bring up the object from the session update the information accordingly and try to update it. The update failed with the following message:

org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER/ MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.

I am thinking, because I am calling the same action/bean, would it be possible that I am using the same session from the previous action called which is read only by the "OpenSessionInViewFilter"? It's a long shot, but could this be possible?

Thanks,
Doug




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to