Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » Detached Instance Following (read-only) Query(Recommended Practise: Detached Instance Following (read-only) Query)
Detached Instance Following (read-only) Query [message #801741] Sat, 18 February 2012 17:08 Go to next message
Eclipse UserFriend
The SOAj implementation of EclipseLink includes the following in base class queries:

// This hint ensure that the shared instance be returned from cache.
query.setHint(QueryHints.READ_ONLY, HintValues.TRUE);

Therefore, what is the recommended practise to obtain a detached copy for updating a cached instance returned with a query? Is it?

persistenceResouceFacade.detach(myCachedInstanceOtainedViaQuery);

If so, what happens when two threads attempt to update and detach the same instance?

Re: Detached Instance Following (read-only) Query [message #804379 is a reply to message #801741] Wed, 22 February 2012 10:06 Go to previous messageGo to next message
Eclipse UserFriend
What is SOAj?
Re: Detached Instance Following (read-only) Query [message #804438 is a reply to message #804379] Wed, 22 February 2012 11:21 Go to previous messageGo to next message
Eclipse UserFriend
- The Short Answer -
SOAj ( http://info.soaj ) is the reference implementation supporting "Pattern Enabled Development SM" ( http://PatternEnabled.com ).

- A More Complete Response -
These brief YouTube links might help:

http://youtu.be/-R-vA_Tc2fM

http://youtu.be/O6-zcR0XSmE

- More Importantly -
If our approach is to have all queries return Shared (Level 2) Cached instances... what is the best strategy for proceeding with an update based on an instance returned from a query?
Re: Detached Instance Following (read-only) Query [message #804636 is a reply to message #804438] Wed, 22 February 2012 15:59 Go to previous messageGo to next message
Eclipse UserFriend
I'm now thinking that if queries are consistently configured for read-only... that all relationships [for example - @OneToOne(cascade=CascadeType.DETACH)] should be coded consistently. Anyone agree?
Re: Detached Instance Following (read-only) Query [message #808370 is a reply to message #804636] Mon, 27 February 2012 13:08 Go to previous message
Eclipse UserFriend
You cannot (should not) modify read-only instances.

To update a read-only instance, you must,
- begin a transaction in the EntityMamnager
- register it with an EntityManager (em.find(), or em.merge())
- modify the object returned from the EntityManagers persistence context.
- commit the transaction in the EntityManager

If you want to be able to update the objects, then maybe read-only is not what you want. Perhaps just have some sort of singleton EntityManager that you read everything through to maintain object identity.

Previous Topic:NPE in remote session
Next Topic:Recommended Practise: Consistent Timestamp for Unit of Work
Goto Forum:
  


Current Time: Fri Jul 04 03:43:50 EDT 2025

Powered by FUDForum. Page generated in 0.04376 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top