Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 323954 - Removing an element from the middle of a @ElementCollection with @OrderColumn hangs up EclipseLink
Summary: Removing an element from the middle of a @ElementCollection with @OrderColumn...
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P2 major (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-30 07:24 EDT by Igor Mukhin CLA
Modified: 2022-06-09 10:34 EDT (History)
4 users (show)

See Also:


Attachments
Suggested patch. (8.17 KB, patch)
2010-09-24 16:21 EDT, Andrei Ilitchev CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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