Mark Spritzler wrote:It looks like the entire method is a use case and would expect you want transaction started there and coomit/rollback based on success or failure of the entire use case.
Then you can define a bean for a TransactionManager and add <tx:annotation-driven> then you just add an @Transactional annotation on the top of your method.
Mark
Mark Spritzler wrote:If you create individual transactions per loop, then you will be using more than one Connection, which isn't a great use of a scarce resource.
But if you have to, I recommend moving that code that is transactional into its own public method, and add the @Transactional annotation to it.
Mark
Julien Martin wrote:
Mark Spritzler wrote:If you create individual transactions per loop, then you will be using more than one Connection, which isn't a great use of a scarce resource.
But if you have to, I recommend moving that code that is transactional into its own public method, and add the @Transactional annotation to it.
Mark
Hi Mark,
Why a public method? Can't I use a private method?
Good point about the number of connections. I was not aware of that problem. Is there not a way to avoid using more than one Connection (apart from using an annotation arount the whole method)?
Regards,
Julien.
Julien Martin wrote:Thanks Mark for this detailed reply. I am going to order the book you advised as soon as it is available.
Regards,
Julien.
Julien Martin wrote:Thanks Mark. I would like to mark this as resolved but I can't find the button...
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |