-
Dec 18th, 2005, 06:23 PM
#1
Transactions in Spring
Hi,
I am new to the spring framework. I am trying to modify the code to use the spring framework.
The original code is
----------------------------------------
Connection conn;
conn.setAutoCommit(false);
addRecord(); //adds arecord into table
updateTable(); // updates another table
conn.commit();
autoCommit = true;
conn.setAutoCommit(autoCommit);
-------------------------------------------
I am using the Spring BeanFactory to get the connection..
Could anyone help me regarding this.. It would be a great help
Thanks
-
Dec 18th, 2005, 08:35 PM
#2
Hi
Hibernate becomes a bit different when used with spring . And A LOT easyer in the end .
This would be a good place to start . You can also find tons of examples in most of the posts in this section
good luck
-
Dec 19th, 2005, 08:25 AM
#3
Thanks for the reply. But I was looking for something with plain JDBC and Spring. Could someone post an example.
Thank you
-
Dec 19th, 2005, 08:41 AM
#4
oh sorry , i got ahead of myself , and thought you were using hibernate , must have been too late at night
well hibernate was chapter 12 , so if you want to step backwards to jdbc here's chapter 11
-
Dec 19th, 2005, 11:40 AM
#5
TransactionTemplate tt = new TransactionTemplate();
tt.execute(new TransactionCallbackWithoutResult()
{
protected void doInTransactionWithoutResult(TransactionStatus status)
{
updateRecord();
updateDifferentRecord();
}});
I have written the above code...the two updates have to be done in one transaction.. I am not sure whether this is the correct code....I was concerned about the begin and commit transaction methods in the previous code which are not there in this code....It would be of great help if someone could correct me if the abovce code is wrong, and also please let me know how the begin and commit transactions are handled in the above code..
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules