Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: One transaction per request w/Hibernate

  1. #11

    Default

    I actually found a good pattern to use for what I wanted to do. Since, I'm using Webwork it was pretty easy to have a transaction start and close and the beginning and ending of the processing of each of my action invocations.

  2. #12
    Join Date
    Aug 2004
    Posts
    1

    Default

    Quote Originally Posted by ehauser
    I actually found a good pattern to use for what I wanted to do. Since, I'm using Webwork it was pretty easy to have a transaction start and close and the beginning and ending of the processing of each of my action invocations.
    I've been using WebWork 2 and Spring in conjunction in a project that started in December 2003. At that time nobody had published a really compelling and simple integration between the two, so I made a home-grown solution that basically replaced WebWork's action factory with a simple factory that basically just autowires the WW actions via their constructors (PicoContainer -style). It's worked very well.

    In my project, I also considered WebWork actions to be natural units-of-work (like adding a user, creating a news article etc), so I made my transaction handling work so that each action invocation occured in a single transaction.

    My actions interact with different services and domain objects and all db access calls are executed in the same tx context. Spring works great for stuff like this (already back then, and 'tis maturing all the time).

  3. #13
    Join Date
    Sep 2004
    Posts
    346

    Default I'm having same issue. Any resolution on this?

    I'm having same issue. Any resolution on this?

  4. #14

    Default Re: I'm having same issue. Any resolution on this?

    Quote Originally Posted by garpinc2
    I'm having same issue. Any resolution on this?
    I eventually found a solution that works pretty well for me. I have an interceptor in Webwork's stack that doesn't do anything, but it allows for every action to execute under a single transaction.

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

    <bean id="transactionInterceptorTarget" class="ii.webwork.interceptor.TransactionIntercept or" />

    Then, I use the following for all of my DAO managers:

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

    This works like a charm. I'm using the xwork-spring integration library. It's available at https://xwork-optional.dev.java.net/

  5. #15
    Join Date
    Sep 2004
    Posts
    346

    Default Can't find that class. Please advise.

    Can't find that class. Please advise. ii.webwork.interceptor.TransactionInterceptor

    Also any ideas about how I could adapt this for Struts

  6. #16

    Default Re: Can't find that class. Please advise.

    Quote Originally Posted by garpinc2
    Can't find that class. Please advise. ii.webwork.interceptor.TransactionInterceptor

    Also any ideas about how I could adapt this for Struts
    That class is specific to my individual project. It doesn't really apply to Struts because interceptors do not exist in the Struts framework. There is a sample chapter for Spring Live which discusses Spring integration with Struts. I'm assuming that there is a probably a method in the Spring controller for Struts that you could use for transaction demarcation, and achieve the similar affect.

  7. #17
    Join Date
    Sep 2004
    Posts
    346

    Default Actually...

    A little while ago we created ServletWrappingController which supports Spring interceptors for Struts. Maybe posting the code here would help me out.

  8. #18
    Join Date
    Sep 2004
    Posts
    346

    Default I'm still waiting on your posting...

    I'm still waiting on your posting...

    Thanks,
    Garry

Similar Threads

  1. Replies: 9
    Last Post: Nov 1st, 2005, 10:36 PM
  2. Unit testing with JOTM and JtaTransactionManager
    By lalle in forum Architecture
    Replies: 1
    Last Post: Oct 15th, 2005, 09:05 AM
  3. Replies: 3
    Last Post: May 16th, 2005, 07:04 AM
  4. Replies: 3
    Last Post: Nov 19th, 2004, 07:16 PM
  5. Transaction pb Hibernate/MySQL
    By syluser in forum Data
    Replies: 2
    Last Post: Aug 28th, 2004, 02:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •