Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » When a merge does not update? (Sametimes the merge does not update, I would know that restrictions to better use this JPA implementation)
When a merge does not update? [message #1060076] Wed, 22 May 2013 22:45 Go to next message
Everton Fujimoto is currently offline Everton FujimotoFriend
Messages: 6
Registered: June 2012
Junior Member
A example:

Using primefaces, when I list a data in a dataTable with LazyDataModel and get a entity with LazyDataModel.getRowData(), I change values but nothing value is updated in EntityManager.merge().

A more strange is when I process a new request (with session or view JSF bean), the data can be updated in merge... (same entity, stored in session).

detach a entity not fix...

But if I get the data from EntityManager without get a entity from getRowData(), can be updated...

Other strange point is when I get a data with getRowData(), if I get a entity from entityManager from ID, the entity not be updated...

Sorry for my bad english, i'm brazilian...
Re: When a merge does not update? [message #1060805 is a reply to message #1060076] Tue, 28 May 2013 13:23 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Ensure you are calling merge on the correct EntityManager that is in a transaction.

Check you merge cascading, you may be merging the same object twice, and only one of the copies may have your changes.

Print the objects data before and after calling merge to ensure it was merged correctly. Try calling flush() directly after the merge to see if the changes were picked up.

Enable logging on finest to see what is occurring, or try debugging.

Are you using field or property access? Be careful of side-affects in get/set method for property access.

If still having issues, include your code and log.



James : Wiki : Book : Blog : Twitter
Re: When a merge does not update? [message #1061736 is a reply to message #1060805] Mon, 03 June 2013 16:34 Go to previous messageGo to next message
Everton Fujimoto is currently offline Everton FujimotoFriend
Messages: 6
Registered: June 2012
Junior Member
Hello, i'm already has make this... The problem, more detailed:

I'm using Java Server Faces 2.1 Mojarra, Primefaces 3.5, Glassfish 3.2.1.1, Eclipselink 2.4, EJB3 to control transactions and inject EntityManager's.

Using Primefaces LazyDataModel, i'm calling super.getRowData() to get entity to merge, this method find in LazyDataModel inner List the entity, retrieved in other request by TypedQuery (returning the List used from LazyDataModel) and when I get the data from that List, in same request, merge don't store the changes in this object... But, if I get the element (without get by LazyDataModel), directly from entitymanager, merge can update this element.

A very strange is the element, if I get a copy from LazyDataModel, and I get other copy from entityManager, nothing of copy's store with merge.

I think that List in LazyDataModel are a IndirectList from EntityManager, inserted in a LazyDataModel, does not detach the elements from EntityManager after out of the EJB scope (or the Request is finalized), and the changes "poison" the cache... I will make a project example to send here, but this week I have not time...

If is that I think, you know how I can solve? What you think it's?
Re: When a merge does not update? [message #1061744 is a reply to message #1061736] Mon, 03 June 2013 17:35 Go to previous message
Everton Fujimoto is currently offline Everton FujimotoFriend
Messages: 6
Registered: June 2012
Junior Member
I'm find the problem... nothing like I think...

I've forget this query hint:

q.setHint(QueryHints.READ_ONLY, HintValues.TRUE);

And for this the cache has poisoned...
Previous Topic:Cascade Remove problem
Next Topic:JMS Cache coordination
Goto Forum:
  


Current Time: Thu Apr 25 15:11:18 GMT 2024

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

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

Back to the top