• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transactions in iBATIS

 
Peter Braun
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

The basic principles and advantages of iBATIS is obvious for me and I think it could be effective/productive.
But what about advanced features? For example how can transactions be used with iBATIS?

Thanks,
Peter
 
Brandon Goodin
author
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Transaction support is available in iBATIS. You can demarcate your transactions directly with the sqlmap. iBATIS is also open enough to allow for sqlmap transactions to be managed by other frameworks like Spring.

Here is an example of direct sqlmap transaction management:

public updateItemDescription (String itemId, String newDescription)
throws SQLException {
try {
sqlMap.startTransaction ();
Item item = (Item) sqlMap.queryForObject ("getItem", itemId);
item.setDescription (newDescription);
sqlMap.update ("updateItem", item);
sqlMap.commitTransaction ();
} finally {
sqlMap.endTransaction ();
}
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic