You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Jerry Carter (JIRA)" <ji...@apache.org> on 2010/04/21 17:11:53 UTC

[jira] Created: (OPENJPA-1636) Updates to an @ElementCollection are not alway caught

Updates to an @ElementCollection are not alway caught
-----------------------------------------------------

                 Key: OPENJPA-1636
                 URL: https://issues.apache.org/jira/browse/OPENJPA-1636
             Project: OpenJPA
          Issue Type: Bug
    Affects Versions: 2.0.0-beta3
         Environment: Spring 3.0.1, Mac OS X 10.6
            Reporter: Jerry Carter


As part of a complex project, I have a class 'Child' inherited from 'Parent' (i.e. InheritanceType.JOINED).  Within 'Child' are two @ElementCollection fields.  Under some circumstances, updates to these fields are ignored by the EntityManager BUT it is not yet clear exactly what is triggering this behavior.

This one works:
	Child child  = em.find(Child.class, 3071151);
	em.detach(child);
	child.setName("Test Update In Place - Update B");
	Collection<ChildNote> notes = child.getNotes();
	ChildNote note = new ChildNote("Note B");
	notes.add(note);
	child.setNotes(notes);
	em.merge(.updateLocality(loc);
		
	SELECT ... FROM child_data t0 INNER JOIN parent_data t1 ON t0.id = t1.id LEFT OUTER JOIN child_notes t2 ON t0.id = t2.child_ref WHERE t0.id = ?
	DELETE FROM child_notes WHERE child_ref = ?
	UPDATE parent_data SET name = ?, version = ? WHERE id = ? AND version = ? [params=(String) Test Update In Place - Update B, (int) 3, (long) 3071151, (int) 2]
	INSERT INTO child_notes (child_ref, note) VALUES (?, ?) [params=(long) 3071151, (String) Note A]
	INSERT INTO child_notes (child_ref, note) VALUES (?, ?) [params=(long) 3071151, (String) Note B]

Here you can see the SELECT to populate the record.  On the merge, the old 'child_notes' associated with the record are deleted and the values repopulated. All is good.  But in the very next test, I delete a note:

	Child child  = em.find(Child.class, 3071151);
	em.detach(child);
	child.setName("Test Update In Place - Update C");
	Collection<ChildNote> notes = child.getNotes();
	Iterator<ChildNote> i = child.iterator();
	ChildNote eliminateMe = i.next();
	notes.remove(eliminateMe);
	// child.setNotes(null); // TODO: Workaround for OPENJPA-xxxx
	child.setNotes(notes);
	em.merge(.updateLocality(loc);

	SELECT ... FROM child_data t0 INNER JOIN parent_data t1 ON t0.id = t1.id LEFT OUTER JOIN child_notes t2 ON t0.id = t2.child_ref WHERE t0.id = ?
	UPDATE parent_data SET name = ?, version = ? WHERE id = ? AND version = ? [params=(String) Test Update In Place - Update C, (int) 4, (long) 3071151, (int) 3]

This is the same sequence of operations, save for a note being removed as opposed to added.  Here the 'child_notes' are not cleared and repopulated!  Adding the 'child.setNotes(null)' call, however, restores the correct behavior.

	SELECT ... FROM child_data t0 INNER JOIN parent_data t1 ON t0.id = t1.id LEFT OUTER JOIN child_notes t2 ON t0.id = t2.child_ref WHERE t0.id = ?
	DELETE FROM child_notes WHERE child_ref = ?
	UPDATE parent_data SET name = ?, version = ? WHERE id = ? AND version = ? [params=(String) Test Update In Place - Update C, (int) 4, (long) 3071151, (int) 3]
	INSERT INTO child_notes (child_ref, note) VALUES (?, ?) [params=(long) 3071151, (String) Note A]



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (OPENJPA-1636) Updates to an @ElementCollection are not alway caught

Posted by "Donald Woods (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-1636?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Donald Woods closed OPENJPA-1636.
---------------------------------

    Fix Version/s: 2.0.0
       Resolution: Duplicate

Fixed by OPENJPA-1597

> Updates to an @ElementCollection are not alway caught
> -----------------------------------------------------
>
>                 Key: OPENJPA-1636
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1636
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.0.0-beta3
>         Environment: Spring 3.0.1, Mac OS X 10.6
>            Reporter: Jerry Carter
>             Fix For: 2.0.0
>
>
> As part of a complex project, I have a class 'Child' inherited from 'Parent' (i.e. InheritanceType.JOINED).  Within 'Child' are two @ElementCollection fields.  Under some circumstances, updates to these fields are ignored by the EntityManager BUT it is not yet clear exactly what is triggering this behavior.
> This one works:
> 	Child child  = em.find(Child.class, 3071151);
> 	em.detach(child);
> 	child.setName("Test Update In Place - Update B");
> 	Collection<ChildNote> notes = child.getNotes();
> 	ChildNote note = new ChildNote("Note B");
> 	notes.add(note);
> 	child.setNotes(notes);
> 	em.merge(.updateLocality(loc);
> 		
> 	SELECT ... FROM child_data t0 INNER JOIN parent_data t1 ON t0.id = t1.id LEFT OUTER JOIN child_notes t2 ON t0.id = t2.child_ref WHERE t0.id = ?
> 	DELETE FROM child_notes WHERE child_ref = ?
> 	UPDATE parent_data SET name = ?, version = ? WHERE id = ? AND version = ? [params=(String) Test Update In Place - Update B, (int) 3, (long) 3071151, (int) 2]
> 	INSERT INTO child_notes (child_ref, note) VALUES (?, ?) [params=(long) 3071151, (String) Note A]
> 	INSERT INTO child_notes (child_ref, note) VALUES (?, ?) [params=(long) 3071151, (String) Note B]
> Here you can see the SELECT to populate the record.  On the merge, the old 'child_notes' associated with the record are deleted and the values repopulated. All is good.  But in the very next test, I delete a note:
> 	Child child  = em.find(Child.class, 3071151);
> 	em.detach(child);
> 	child.setName("Test Update In Place - Update C");
> 	Collection<ChildNote> notes = child.getNotes();
> 	Iterator<ChildNote> i = child.iterator();
> 	ChildNote eliminateMe = i.next();
> 	notes.remove(eliminateMe);
> 	// child.setNotes(null); // TODO: Workaround for OPENJPA-xxxx
> 	child.setNotes(notes);
> 	em.merge(.updateLocality(loc);
> 	SELECT ... FROM child_data t0 INNER JOIN parent_data t1 ON t0.id = t1.id LEFT OUTER JOIN child_notes t2 ON t0.id = t2.child_ref WHERE t0.id = ?
> 	UPDATE parent_data SET name = ?, version = ? WHERE id = ? AND version = ? [params=(String) Test Update In Place - Update C, (int) 4, (long) 3071151, (int) 3]
> This is the same sequence of operations, save for a note being removed as opposed to added.  Here the 'child_notes' are not cleared and repopulated!  Adding the 'child.setNotes(null)' call, however, restores the correct behavior.
> 	SELECT ... FROM child_data t0 INNER JOIN parent_data t1 ON t0.id = t1.id LEFT OUTER JOIN child_notes t2 ON t0.id = t2.child_ref WHERE t0.id = ?
> 	DELETE FROM child_notes WHERE child_ref = ?
> 	UPDATE parent_data SET name = ?, version = ? WHERE id = ? AND version = ? [params=(String) Test Update In Place - Update C, (int) 4, (long) 3071151, (int) 3]
> 	INSERT INTO child_notes (child_ref, note) VALUES (?, ?) [params=(long) 3071151, (String) Note A]

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-1636) Updates to an @ElementCollection are not alway caught

Posted by "Jerry Carter (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-1636?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12859424#action_12859424 ] 

Jerry Carter commented on OPENJPA-1636:
---------------------------------------

NOTE: I see the correct behavior in the 2.0.0 build.  I've walked through the 33 issues fixed between 2.0.0-beta3 and 2.0.0, but none of the fixes seem to relate to this.

> Updates to an @ElementCollection are not alway caught
> -----------------------------------------------------
>
>                 Key: OPENJPA-1636
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1636
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.0.0-beta3
>         Environment: Spring 3.0.1, Mac OS X 10.6
>            Reporter: Jerry Carter
>
> As part of a complex project, I have a class 'Child' inherited from 'Parent' (i.e. InheritanceType.JOINED).  Within 'Child' are two @ElementCollection fields.  Under some circumstances, updates to these fields are ignored by the EntityManager BUT it is not yet clear exactly what is triggering this behavior.
> This one works:
> 	Child child  = em.find(Child.class, 3071151);
> 	em.detach(child);
> 	child.setName("Test Update In Place - Update B");
> 	Collection<ChildNote> notes = child.getNotes();
> 	ChildNote note = new ChildNote("Note B");
> 	notes.add(note);
> 	child.setNotes(notes);
> 	em.merge(.updateLocality(loc);
> 		
> 	SELECT ... FROM child_data t0 INNER JOIN parent_data t1 ON t0.id = t1.id LEFT OUTER JOIN child_notes t2 ON t0.id = t2.child_ref WHERE t0.id = ?
> 	DELETE FROM child_notes WHERE child_ref = ?
> 	UPDATE parent_data SET name = ?, version = ? WHERE id = ? AND version = ? [params=(String) Test Update In Place - Update B, (int) 3, (long) 3071151, (int) 2]
> 	INSERT INTO child_notes (child_ref, note) VALUES (?, ?) [params=(long) 3071151, (String) Note A]
> 	INSERT INTO child_notes (child_ref, note) VALUES (?, ?) [params=(long) 3071151, (String) Note B]
> Here you can see the SELECT to populate the record.  On the merge, the old 'child_notes' associated with the record are deleted and the values repopulated. All is good.  But in the very next test, I delete a note:
> 	Child child  = em.find(Child.class, 3071151);
> 	em.detach(child);
> 	child.setName("Test Update In Place - Update C");
> 	Collection<ChildNote> notes = child.getNotes();
> 	Iterator<ChildNote> i = child.iterator();
> 	ChildNote eliminateMe = i.next();
> 	notes.remove(eliminateMe);
> 	// child.setNotes(null); // TODO: Workaround for OPENJPA-xxxx
> 	child.setNotes(notes);
> 	em.merge(.updateLocality(loc);
> 	SELECT ... FROM child_data t0 INNER JOIN parent_data t1 ON t0.id = t1.id LEFT OUTER JOIN child_notes t2 ON t0.id = t2.child_ref WHERE t0.id = ?
> 	UPDATE parent_data SET name = ?, version = ? WHERE id = ? AND version = ? [params=(String) Test Update In Place - Update C, (int) 4, (long) 3071151, (int) 3]
> This is the same sequence of operations, save for a note being removed as opposed to added.  Here the 'child_notes' are not cleared and repopulated!  Adding the 'child.setNotes(null)' call, however, restores the correct behavior.
> 	SELECT ... FROM child_data t0 INNER JOIN parent_data t1 ON t0.id = t1.id LEFT OUTER JOIN child_notes t2 ON t0.id = t2.child_ref WHERE t0.id = ?
> 	DELETE FROM child_notes WHERE child_ref = ?
> 	UPDATE parent_data SET name = ?, version = ? WHERE id = ? AND version = ? [params=(String) Test Update In Place - Update C, (int) 4, (long) 3071151, (int) 3]
> 	INSERT INTO child_notes (child_ref, note) VALUES (?, ?) [params=(long) 3071151, (String) Note A]

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-1636) Updates to an @ElementCollection are not alway caught

Posted by "Donald Woods (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-1636?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12859455#action_12859455 ] 

Donald Woods commented on OPENJPA-1636:
---------------------------------------

1597 was used to remove some of the changes made in 1097 (like forcing the $proxy classes to be removed when entities were detached which broke collections as in your case).  It was also used to add a new Compatibility setting so JPA 1.0 apps would use the old OpenJPA 1.x serialization behavior and allow JPA 2.0 apps to revert back to the old behavior if needed.


> Updates to an @ElementCollection are not alway caught
> -----------------------------------------------------
>
>                 Key: OPENJPA-1636
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1636
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.0.0-beta3
>         Environment: Spring 3.0.1, Mac OS X 10.6
>            Reporter: Jerry Carter
>             Fix For: 2.0.0
>
>
> As part of a complex project, I have a class 'Child' inherited from 'Parent' (i.e. InheritanceType.JOINED).  Within 'Child' are two @ElementCollection fields.  Under some circumstances, updates to these fields are ignored by the EntityManager BUT it is not yet clear exactly what is triggering this behavior.
> This one works:
> 	Child child  = em.find(Child.class, 3071151);
> 	em.detach(child);
> 	child.setName("Test Update In Place - Update B");
> 	Collection<ChildNote> notes = child.getNotes();
> 	ChildNote note = new ChildNote("Note B");
> 	notes.add(note);
> 	child.setNotes(notes);
> 	em.merge(.updateLocality(loc);
> 		
> 	SELECT ... FROM child_data t0 INNER JOIN parent_data t1 ON t0.id = t1.id LEFT OUTER JOIN child_notes t2 ON t0.id = t2.child_ref WHERE t0.id = ?
> 	DELETE FROM child_notes WHERE child_ref = ?
> 	UPDATE parent_data SET name = ?, version = ? WHERE id = ? AND version = ? [params=(String) Test Update In Place - Update B, (int) 3, (long) 3071151, (int) 2]
> 	INSERT INTO child_notes (child_ref, note) VALUES (?, ?) [params=(long) 3071151, (String) Note A]
> 	INSERT INTO child_notes (child_ref, note) VALUES (?, ?) [params=(long) 3071151, (String) Note B]
> Here you can see the SELECT to populate the record.  On the merge, the old 'child_notes' associated with the record are deleted and the values repopulated. All is good.  But in the very next test, I delete a note:
> 	Child child  = em.find(Child.class, 3071151);
> 	em.detach(child);
> 	child.setName("Test Update In Place - Update C");
> 	Collection<ChildNote> notes = child.getNotes();
> 	Iterator<ChildNote> i = child.iterator();
> 	ChildNote eliminateMe = i.next();
> 	notes.remove(eliminateMe);
> 	// child.setNotes(null); // TODO: Workaround for OPENJPA-xxxx
> 	child.setNotes(notes);
> 	em.merge(.updateLocality(loc);
> 	SELECT ... FROM child_data t0 INNER JOIN parent_data t1 ON t0.id = t1.id LEFT OUTER JOIN child_notes t2 ON t0.id = t2.child_ref WHERE t0.id = ?
> 	UPDATE parent_data SET name = ?, version = ? WHERE id = ? AND version = ? [params=(String) Test Update In Place - Update C, (int) 4, (long) 3071151, (int) 3]
> This is the same sequence of operations, save for a note being removed as opposed to added.  Here the 'child_notes' are not cleared and repopulated!  Adding the 'child.setNotes(null)' call, however, restores the correct behavior.
> 	SELECT ... FROM child_data t0 INNER JOIN parent_data t1 ON t0.id = t1.id LEFT OUTER JOIN child_notes t2 ON t0.id = t2.child_ref WHERE t0.id = ?
> 	DELETE FROM child_notes WHERE child_ref = ?
> 	UPDATE parent_data SET name = ?, version = ? WHERE id = ? AND version = ? [params=(String) Test Update In Place - Update C, (int) 4, (long) 3071151, (int) 3]
> 	INSERT INTO child_notes (child_ref, note) VALUES (?, ?) [params=(long) 3071151, (String) Note A]

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-1636) Updates to an @ElementCollection are not alway caught

Posted by "Jerry Carter (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-1636?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12859447#action_12859447 ] 

Jerry Carter commented on OPENJPA-1636:
---------------------------------------

That would be wonderful news but are you sure?  If I read the logs correctly, OPENJPA-1097 went into 2.0.0-beta3 which is most definitely broken.

> Updates to an @ElementCollection are not alway caught
> -----------------------------------------------------
>
>                 Key: OPENJPA-1636
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1636
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.0.0-beta3
>         Environment: Spring 3.0.1, Mac OS X 10.6
>            Reporter: Jerry Carter
>             Fix For: 2.0.0
>
>
> As part of a complex project, I have a class 'Child' inherited from 'Parent' (i.e. InheritanceType.JOINED).  Within 'Child' are two @ElementCollection fields.  Under some circumstances, updates to these fields are ignored by the EntityManager BUT it is not yet clear exactly what is triggering this behavior.
> This one works:
> 	Child child  = em.find(Child.class, 3071151);
> 	em.detach(child);
> 	child.setName("Test Update In Place - Update B");
> 	Collection<ChildNote> notes = child.getNotes();
> 	ChildNote note = new ChildNote("Note B");
> 	notes.add(note);
> 	child.setNotes(notes);
> 	em.merge(.updateLocality(loc);
> 		
> 	SELECT ... FROM child_data t0 INNER JOIN parent_data t1 ON t0.id = t1.id LEFT OUTER JOIN child_notes t2 ON t0.id = t2.child_ref WHERE t0.id = ?
> 	DELETE FROM child_notes WHERE child_ref = ?
> 	UPDATE parent_data SET name = ?, version = ? WHERE id = ? AND version = ? [params=(String) Test Update In Place - Update B, (int) 3, (long) 3071151, (int) 2]
> 	INSERT INTO child_notes (child_ref, note) VALUES (?, ?) [params=(long) 3071151, (String) Note A]
> 	INSERT INTO child_notes (child_ref, note) VALUES (?, ?) [params=(long) 3071151, (String) Note B]
> Here you can see the SELECT to populate the record.  On the merge, the old 'child_notes' associated with the record are deleted and the values repopulated. All is good.  But in the very next test, I delete a note:
> 	Child child  = em.find(Child.class, 3071151);
> 	em.detach(child);
> 	child.setName("Test Update In Place - Update C");
> 	Collection<ChildNote> notes = child.getNotes();
> 	Iterator<ChildNote> i = child.iterator();
> 	ChildNote eliminateMe = i.next();
> 	notes.remove(eliminateMe);
> 	// child.setNotes(null); // TODO: Workaround for OPENJPA-xxxx
> 	child.setNotes(notes);
> 	em.merge(.updateLocality(loc);
> 	SELECT ... FROM child_data t0 INNER JOIN parent_data t1 ON t0.id = t1.id LEFT OUTER JOIN child_notes t2 ON t0.id = t2.child_ref WHERE t0.id = ?
> 	UPDATE parent_data SET name = ?, version = ? WHERE id = ? AND version = ? [params=(String) Test Update In Place - Update C, (int) 4, (long) 3071151, (int) 3]
> This is the same sequence of operations, save for a note being removed as opposed to added.  Here the 'child_notes' are not cleared and repopulated!  Adding the 'child.setNotes(null)' call, however, restores the correct behavior.
> 	SELECT ... FROM child_data t0 INNER JOIN parent_data t1 ON t0.id = t1.id LEFT OUTER JOIN child_notes t2 ON t0.id = t2.child_ref WHERE t0.id = ?
> 	DELETE FROM child_notes WHERE child_ref = ?
> 	UPDATE parent_data SET name = ?, version = ? WHERE id = ? AND version = ? [params=(String) Test Update In Place - Update C, (int) 4, (long) 3071151, (int) 3]
> 	INSERT INTO child_notes (child_ref, note) VALUES (?, ?) [params=(long) 3071151, (String) Note A]

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-1636) Updates to an @ElementCollection are not alway caught

Posted by "Jerry Carter (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-1636?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12859448#action_12859448 ] 

Jerry Carter commented on OPENJPA-1636:
---------------------------------------

Oops.  I read the wrong issue.  I see that OPENJPA-1597 went in later.  Thanks much.

> Updates to an @ElementCollection are not alway caught
> -----------------------------------------------------
>
>                 Key: OPENJPA-1636
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1636
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.0.0-beta3
>         Environment: Spring 3.0.1, Mac OS X 10.6
>            Reporter: Jerry Carter
>             Fix For: 2.0.0
>
>
> As part of a complex project, I have a class 'Child' inherited from 'Parent' (i.e. InheritanceType.JOINED).  Within 'Child' are two @ElementCollection fields.  Under some circumstances, updates to these fields are ignored by the EntityManager BUT it is not yet clear exactly what is triggering this behavior.
> This one works:
> 	Child child  = em.find(Child.class, 3071151);
> 	em.detach(child);
> 	child.setName("Test Update In Place - Update B");
> 	Collection<ChildNote> notes = child.getNotes();
> 	ChildNote note = new ChildNote("Note B");
> 	notes.add(note);
> 	child.setNotes(notes);
> 	em.merge(.updateLocality(loc);
> 		
> 	SELECT ... FROM child_data t0 INNER JOIN parent_data t1 ON t0.id = t1.id LEFT OUTER JOIN child_notes t2 ON t0.id = t2.child_ref WHERE t0.id = ?
> 	DELETE FROM child_notes WHERE child_ref = ?
> 	UPDATE parent_data SET name = ?, version = ? WHERE id = ? AND version = ? [params=(String) Test Update In Place - Update B, (int) 3, (long) 3071151, (int) 2]
> 	INSERT INTO child_notes (child_ref, note) VALUES (?, ?) [params=(long) 3071151, (String) Note A]
> 	INSERT INTO child_notes (child_ref, note) VALUES (?, ?) [params=(long) 3071151, (String) Note B]
> Here you can see the SELECT to populate the record.  On the merge, the old 'child_notes' associated with the record are deleted and the values repopulated. All is good.  But in the very next test, I delete a note:
> 	Child child  = em.find(Child.class, 3071151);
> 	em.detach(child);
> 	child.setName("Test Update In Place - Update C");
> 	Collection<ChildNote> notes = child.getNotes();
> 	Iterator<ChildNote> i = child.iterator();
> 	ChildNote eliminateMe = i.next();
> 	notes.remove(eliminateMe);
> 	// child.setNotes(null); // TODO: Workaround for OPENJPA-xxxx
> 	child.setNotes(notes);
> 	em.merge(.updateLocality(loc);
> 	SELECT ... FROM child_data t0 INNER JOIN parent_data t1 ON t0.id = t1.id LEFT OUTER JOIN child_notes t2 ON t0.id = t2.child_ref WHERE t0.id = ?
> 	UPDATE parent_data SET name = ?, version = ? WHERE id = ? AND version = ? [params=(String) Test Update In Place - Update C, (int) 4, (long) 3071151, (int) 3]
> This is the same sequence of operations, save for a note being removed as opposed to added.  Here the 'child_notes' are not cleared and repopulated!  Adding the 'child.setNotes(null)' call, however, restores the correct behavior.
> 	SELECT ... FROM child_data t0 INNER JOIN parent_data t1 ON t0.id = t1.id LEFT OUTER JOIN child_notes t2 ON t0.id = t2.child_ref WHERE t0.id = ?
> 	DELETE FROM child_notes WHERE child_ref = ?
> 	UPDATE parent_data SET name = ?, version = ? WHERE id = ? AND version = ? [params=(String) Test Update In Place - Update C, (int) 4, (long) 3071151, (int) 3]
> 	INSERT INTO child_notes (child_ref, note) VALUES (?, ?) [params=(long) 3071151, (String) Note A]

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-1636) Updates to an @ElementCollection are not alway caught

Posted by "Donald Woods (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-1636?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12859444#action_12859444 ] 

Donald Woods commented on OPENJPA-1636:
---------------------------------------

It's probably related to the OPENJPA-1097 changes in Beta3, which I fixed using OPENJPA-1597 in 2.0.0.
Glad to hear that your problem went away with the final 2.0.0 code.

> Updates to an @ElementCollection are not alway caught
> -----------------------------------------------------
>
>                 Key: OPENJPA-1636
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1636
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.0.0-beta3
>         Environment: Spring 3.0.1, Mac OS X 10.6
>            Reporter: Jerry Carter
>
> As part of a complex project, I have a class 'Child' inherited from 'Parent' (i.e. InheritanceType.JOINED).  Within 'Child' are two @ElementCollection fields.  Under some circumstances, updates to these fields are ignored by the EntityManager BUT it is not yet clear exactly what is triggering this behavior.
> This one works:
> 	Child child  = em.find(Child.class, 3071151);
> 	em.detach(child);
> 	child.setName("Test Update In Place - Update B");
> 	Collection<ChildNote> notes = child.getNotes();
> 	ChildNote note = new ChildNote("Note B");
> 	notes.add(note);
> 	child.setNotes(notes);
> 	em.merge(.updateLocality(loc);
> 		
> 	SELECT ... FROM child_data t0 INNER JOIN parent_data t1 ON t0.id = t1.id LEFT OUTER JOIN child_notes t2 ON t0.id = t2.child_ref WHERE t0.id = ?
> 	DELETE FROM child_notes WHERE child_ref = ?
> 	UPDATE parent_data SET name = ?, version = ? WHERE id = ? AND version = ? [params=(String) Test Update In Place - Update B, (int) 3, (long) 3071151, (int) 2]
> 	INSERT INTO child_notes (child_ref, note) VALUES (?, ?) [params=(long) 3071151, (String) Note A]
> 	INSERT INTO child_notes (child_ref, note) VALUES (?, ?) [params=(long) 3071151, (String) Note B]
> Here you can see the SELECT to populate the record.  On the merge, the old 'child_notes' associated with the record are deleted and the values repopulated. All is good.  But in the very next test, I delete a note:
> 	Child child  = em.find(Child.class, 3071151);
> 	em.detach(child);
> 	child.setName("Test Update In Place - Update C");
> 	Collection<ChildNote> notes = child.getNotes();
> 	Iterator<ChildNote> i = child.iterator();
> 	ChildNote eliminateMe = i.next();
> 	notes.remove(eliminateMe);
> 	// child.setNotes(null); // TODO: Workaround for OPENJPA-xxxx
> 	child.setNotes(notes);
> 	em.merge(.updateLocality(loc);
> 	SELECT ... FROM child_data t0 INNER JOIN parent_data t1 ON t0.id = t1.id LEFT OUTER JOIN child_notes t2 ON t0.id = t2.child_ref WHERE t0.id = ?
> 	UPDATE parent_data SET name = ?, version = ? WHERE id = ? AND version = ? [params=(String) Test Update In Place - Update C, (int) 4, (long) 3071151, (int) 3]
> This is the same sequence of operations, save for a note being removed as opposed to added.  Here the 'child_notes' are not cleared and repopulated!  Adding the 'child.setNotes(null)' call, however, restores the correct behavior.
> 	SELECT ... FROM child_data t0 INNER JOIN parent_data t1 ON t0.id = t1.id LEFT OUTER JOIN child_notes t2 ON t0.id = t2.child_ref WHERE t0.id = ?
> 	DELETE FROM child_notes WHERE child_ref = ?
> 	UPDATE parent_data SET name = ?, version = ? WHERE id = ? AND version = ? [params=(String) Test Update In Place - Update C, (int) 4, (long) 3071151, (int) 3]
> 	INSERT INTO child_notes (child_ref, note) VALUES (?, ?) [params=(long) 3071151, (String) Note A]

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.