views:

16

answers:

1

Hi,

I have this scenario in my Spring MVC Apps.

User has to choose what hobbies he/she likes. He can choose at least one or many hobbies. My problem is this, If I need to save the list of hobbies into my DB, I am thinking of sending the list of hobbies that my user has chosen, delimited by a comma separator.

Its like this: Baskteball, Singing, Dancing, Bowling

Now, In my stored procedure call in my DB called by JDBC DAO, I will just parse the List of string and then perform Insert Statements one by one?

I can use also the

Begin Try
 Begin Tran
  //perform series of inserts here
 Commit Tran
End Try
Begin Catch
 Rollback Tran
End Catch

I am thinking that this will limit the amount of transaction from my Spring JDBC to DB. This would guard me also from having incomplete transaction should the second or third insert fails.

I have heard about Spring Transaction Management feature but I really haven't had the chance to study it yet and I am sticking to what I know so far because of Time Constraint. Spring has so many modules and I do not have the time to study them all.

Do you think, given my current knowledge of Spring, my idea is OK? Would like to hear others comments here please.

+1  A: 

The idea of managing your transactions inside a stored procedure is quite old-fashioned, but perfectly valid.

Spring provides JDBC and JTA transaction management, which helps with application-level transaction management. If you want to manage your transactions in the stored procedure instead, then you're not going to have much use for Spring's transaction stuff, so you can safely ignore it.

skaffman
Thanks skaffman. Your comments are really well received. I will try to extend effort to study the transaction management feature. I just had a hard time understanding about AOP on internet tutorials.
Mark Estrada