Forums Register Login

Use transaction with add/update and delete?

+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
Create symphonies in seed and soil. For this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1086 times.
Similar Threads
Problem with One-To-Many bi-directional mapping
transaction question in Change Itinerary use case
Exception handling - regarding
BMP Entity Bean
query regarding EJB transactions.
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 08:58:36.