Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 323954

Summary: Removing an element from the middle of a @ElementCollection with @OrderColumn hangs up EclipseLink
Product: z_Archived Reporter: Igor Mukhin <iimuhin>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: CLOSED FIXED QA Contact:
Severity: major    
Priority: P2 CC: andrei.ilitchev, eclipselink.orm-inbox, michael.f.obrien, tom.ware
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Suggested patch. none

Description Igor Mukhin CLA 2010-08-30 07:24:08 EDT
Build Identifier: 2.1

Removing an element from the middle (not first, not last) of a @ElementCollection with @OrderColumn hangs up EclipseLink.

Reproducible: Always

Steps to Reproduce:
1. Create entititeies


@Entity
public class Person {
	@Id
	@GeneratedValue(strategy=GenerationType.TABLE)
	private int id;

	@Basic
	private String name;

	@ElementCollection
	@CollectionTable(
	        name="PERSON_LOGIN",
	        joinColumns=@JoinColumn(name="PERS_ID", referencedColumnName="ID")
	  )
	@OrderColumn(name="ORDER_COL")
	private List<PersonLogin> logins = new Vector<PersonLogin>();

//...
}

@Embeddable
public class PersonLogin {

	@Basic
	private String username;

	@Basic
	private String password;
//...
}


2. Add the person

		Person p = new Person();
		p.setName("Igor");
		p.getLogins().add(new PersonLogin("igor1", null, 4));
		p.getLogins().add(new PersonLogin("igor2", "pass2", 3));
		p.getLogins().add(new PersonLogin("igor3", "pass3", 2));
		p.getLogins().add(new PersonLogin("igor4", "pass4", 1));

		logStep("inserting new person...");
		em.getTransaction().begin();
		em.persist(p);
		em.getTransaction().commit();


3. Remove an element from the middle (not first, not last) will cause EclipseLink to hang up.

		em.getTransaction().begin();
		p.getLogins().remove(1);
		em.getTransaction().commit(); // it will hang up here
Comment 1 Tom Ware CLA 2010-09-13 10:32:06 EDT
Setting target and priority.  See the following page for information about what these settings mean:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines
Comment 2 Andrei Ilitchev CLA 2010-09-24 16:21:17 EDT
Created attachment 179544 [details]
Suggested patch.

Trivial fix in AggregateCollectionMapping.
Added testDeleteMiddleRecordOfExpertBeerConsumer to InheritedModelJunitTest.
Comment 3 Andrei Ilitchev CLA 2010-09-24 17:15:15 EDT
Checked the fix into both trunk (2.2.) and 2.1.2
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:34:57 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink