• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Best Practice for sharing db transaction across DAO

 
Scott Huffman
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Picture this:

I received a SalesLead that has several SalesLeadFields. I want to save the SalesLead, get it's generated id and then save the SalesLeadFields with that generated id as the foreign key.

You would expect to have a SalesLeadDAO and a SalesLeadFieldDAO. How do I ensure all of the inserts occur within the same transaction? If any insert fails I want the whole thing to rollback.

I'm also running in JBOSS with a datasource in JNDI wanting to use SpringJdbc to manage the datasource and bubbling up to Stripes as the framework.

Am I crazy? Is there a best practice?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34839
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scott,
You would use Spring to manage the transactions. The DAOs would be within that transaction.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic