views:

297

answers:

3

Is there a way to pick-and-choose updates that Hibernate will wrap with a transaction? Inspired by EBay's drive to be transactionless whenever possible, I know of many updates in my application that don't need to be ACID writes. For example, there's an update that consists of a user id and an id for another table. Only one user can insert this record, and I know it doesn't need to be a transaction. So, how do I disable transactions for this one insert, or inserts to this one table?

Edit:

Well, given that my underlying DB is mysql - it looks like I'd have to choose on a table-by-table basis. Any table that didn't need transactions could be set up as myisam instead of innodb. ah, well, not the answer i was looking for.

+1  A: 

See: Hibernate Tx Documentation

The general answer is it depends how you are calling hibernate. The above document explains precisely how you control your transactional boundaries via the Hibernate API's.

Steve Levine
A: 

I dunno anything about Hibernate but my thoughts are:

If you don't Explicitly BEGIN TRANSACTION / COMMIT then it will do-its-stuff (unless you have Implicit Transactions turned on).

If you only have one INSERT / UPDATE per page (unit of work) then that page is inherently ACID, so whether you start and explicit transaction, or not, is not important.

However, an implicit transaction that scoped the whole page's DB transaction would ensure that if you added something in the future, having forgotten that the page did not have Implicit Transaction, you'd save yourself from yourself!

Kristen
A: 

https://www.hibernate.org/403.html

jmpeace