Thanks for your reply.. hmm.. maybe I could use DataSourceTransactionManager instead of HibernateSessionManager, because I'm using JDBC instead of hibernate.
When using this code, where do we place our DAO for accessing database ? tapestry service or spring bean ? Thanks in advance.. On Sat, Dec 11, 2010 at 10:32 PM, Christian Köberl <tapestry.christian.koeb...@gmail.com> wrote: > > I would stick with Spring for transaction handling, since there's a lot of > knowledge and tricks in the Spring transaction management and a lot you > could do wrong. > > We have our own implementation of Spring @Transactional in Tapestry but > we're now switching to a hybrid version using the Spring > PlatformTransactionManager. > > So i think it would be best to add a @Transactional + advise in Tapestry > delegating to Spring PlatformTransactionManager (still using Spring > connection and transaction handling). > > The advise could look something like this: > > public class TransactionalAdvise implements MethodAdvice > { > private final PlatformTransactionManager manager; > > private final int propagation; > > public TransactionalAdvise(HibernateSessionManager manager, int > propagation) > { > super(); > this.manager = manager; > this.propagation = propagation; > } > > public void advise(Invocation invocation) > { > TransactionStatus transactionStatus = > manager.getTransaction(new > DefaultTransactionDefinition(propagation)); > try > { > invocation.proceed(); > } > catch (RuntimeException ex) > { > manager.rollback(transactionStatus); > > throw ex; > } > > // For success or checked exception, commit the transaction. > > manager.commit(transactionStatus); > } > } > > See also > org.apache.tapestry5.internal.hibernate.HibernateTransactionAdvisorImpl in > tapestry-hibernate-core for applying an advise. > > Chris > -- > View this message in context: > http://tapestry-users.832.n2.nabble.com/T5-2-Need-Advice-on-JDBC-and-Transaction-Mgmt-tp5825768p5826301.html > Sent from the Tapestry Users mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org