wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes Use transaction with add/update and delete? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Use transaction with add/update and delete?" Watch "Use transaction with add/update and delete?" New topic
Author

Use transaction with add/update and delete?

C Shinde
Ranch Hand

Joined: Oct 22, 2009
Posts: 60
Why do we use transaction if we want to add a simple record to a DB using an ORM?



What does starting transaction give us in this case?


Regards,
Chetan Shinde
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
All database access is always done in a transaction, that is kind of the point of a database.

The benefits of transactions is that life in a multi-user system would be pretty difficult without them.

TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
xsunil kumar
Ranch Hand

Joined: Dec 14, 2009
Posts: 133
Maintaining transation is required only if you are using application managed transation. If you are using container managed transation, then there is no need to opening transation and comitting it.

I think you are creating entity manager by using entity manager factory. If you are creating entity manager by using entity manager factory, then this is a example of application managed transation and you need to maintain transation other wise your data will not reflect to the database.
Container managed entity manager is not supported in Java SE env. you need to use Java EE env. otherwise in Java SE , you can use container managed entity manager with help of Spring. By using Spring dependency injection.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Use transaction with add/update and delete?