openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Linskey" <plins...@gmail.com>
Subject Re: Object Locking and Application Server (container-managed) environment
Date Wed, 26 Sep 2007 16:50:31 GMT
Hi,

Craig's on point; no need to duck.

So, naming around locking is not ideal in OpenJPA. First, it's
important to note that optimistic locking happens whenever there is a
versioning strategy configured for a class, regardless of pessimistic
locking. So, optimistic locking is implemented completely separately
from pessimistic locking.

The LockManager is there for pessimistic locking. So, the different
calls (and the Read and Write LockLevels) control what level of
locking the LockManager should attempt to obtain. As you allude to,
and as is always the case with locking, if you request a lower lock
level than the connection is providing, OpenJPA won't step the lock
level down, so if you ask for a ReadLockLevel of none and are using
read-committed, then you'll really be getting read-committed locking
on reads.

-Patrick

On 9/26/07, Craig L Russell <Craig.Russell@sun.com> wrote:
> Hi Kevin,
>
> The transaction model for Kodo is based on the pretty well documented
> JDO specification which includes both optimistic and datastore
> transaction semantics. To this model were added the explicit locking
> APIs which complicate things just a bit. But reading the JDO spec
> might be a good start to understand how Kodo worked and therefore how
> OpenJPA's underpinnings work. Ducking now in case there have been
> massive changes to OpenJPA to remove these architecture features...
>
> Craig
>
> On Sep 26, 2007, at 6:00 AM, Kevin Sutter wrote:
>
> > Discovered a useful openjpa property...
> >
> > On 9/25/07, Kevin Sutter <kwsutter@gmail.com> wrote:
> >>
> >> Hi,
> >> I'm trying to figure out the ins and outs of Section 3 Object
> >> Locking as
> >> they relate to running OpenJPA within an application server
> >> (container-managed) environment such as WebSphere.  It seems that
> >> several of
> >> these properties and/or API's are assuming an application-managed
> >> environment outside of a container.  Either that, or there are
> >> implied
> >> behaviors of the container environment that WebSphere is not
> >> providing.
> >>
> >> For example, the ReadLockLevel property allows for none, read, or
> >> write
> >> values.  What does it mean for "none" in an application server
> >> environment?
> >> If the Container has already initiated a global (JTA) transaction,
> >> when
> >> OpenJPA requests a Connection (via the <jta-data-source> element),
> >> this
> >> Connection is automatically enlisted in the Transaction.  Thus,
> >> when the
> >> "Select..." statement is issued, we will get a Read Lock on the
> >> row with the
> >> default isolation level setting (supposed to be Read Committed).
> >> So, how is
> >> OpenJPA supposed to honor the "none" ReadLockLevel request?
> >>
> >> Several places in this section of the document, there are
> >> references to
> >> optimistic and non-optimistic (pessimistic) transactions.  Not lock
> >> managers, but transactions.  The OpenJPA manual indicates that it can
> >> support optimistic transactions by not issuing the database
> >> transaction
> >> until flush or commit time.  But, I don't see how we are can
> >> configure for
> >> the use of optimistic vs pessimistic transactions.  It looks like the
> >> EntityTransaction interface is optimistic by default.  But, is
> >> there anyway
> >> to control the optimisticity (new word) of a global transaction?
> >> The answer
> >> to these questions actually help with the first example outlined
> >> above.
> >
> >
> > Okay.  It was pointed out to me that the openjpa.Optimistic
> > property exists
> > to indicate whether to use optimistic or non-optimistic transaction
> > semantics.  So, it's not just an implicit operation.  But, I guess my
> > question still exists on how this applies to container managed JTA
> > transactions.  I will continue to investigate, but if there are any
> > existing
> > experts in this area, I'd appreciate some insights.  :-)  Thanks!
> >
> > Many other similar questions are in my mind, but let's start with
> > these
> >> since I think these will give a basis for the rest of the discussion.
> >>
> >> Thanks,
> >> Kevin
> >>
>
> Craig Russell
> Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
> 408 276-5638 mailto:Craig.Russell@sun.com
> P.S. A good JDO? O, Gasp!
>
>
>


-- 
Patrick Linskey
202 669 5907

Mime
View raw message