This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Detach Before Transaction Completes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Detach Before Transaction Completes" Watch "Detach Before Transaction Completes" New topic

Detach Before Transaction Completes

Josh Britton

Joined: Nov 26, 2008
Posts: 24
First, I'm really not sure what the best forum is for this question, so I apologize in advance if this is the wrong place.

My situation: I use Hibernate with EJB3, and I use the default transaction behavior. So my transactions last for my whole methods. However, sometimes I want to 'detach' a persistent object before a method completes. There have been several occasions where this seemed useful. Today it's because I get an object using LockMode_UPGRADE at the beginning of a method, then make a small change to the object, then perform the rest of a long method. I no longer need a lock on the object's row during the rest of the method, but I don't know how to release the lock except when the container automatically completes the transaction. Any ideas?


Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32815

Welcome to JavaRanch!

Both Hibernate and EJB 3 are ORM frameworks. So I'll move this to our ORM forum for you.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: Detach Before Transaction Completes
It's not a secret anymore!