OPENJPA-2335 add a unit test for demonstrating the bug

git-svn-id: https://svn.apache.org/repos/asf/openjpa/branches/2.3.x@1538480 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Struberg 2013-11-04 00:00:42 +00:00
parent 065dc9372f
commit 46bd717379
4 changed files with 26 additions and 2 deletions

View File

@ -21,11 +21,14 @@ package org.apache.openjpa.persistence;
import javax.persistence.EntityManager;
import javax.persistence.spi.LoadState;
import junit.framework.Assert;
import org.apache.openjpa.persistence.entity.EntityA;
import org.apache.openjpa.persistence.entity.EntityB;
import org.apache.openjpa.persistence.entity.EntityC;
import org.apache.openjpa.persistence.test.SingleEMFTestCase;
import java.util.Iterator;
/**
*
*/
@ -55,4 +58,21 @@ public class TestOpenJPA2330 extends SingleEMFTestCase {
em.close();
}
public void testOpenJPA2335() {
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
EntityA a = new EntityA();
EntityB b1 = new EntityB(a);
EntityB b2 = new EntityB(a);
a.getBs().add(b1);
a.getBs().add(b2);
em.persist(a);
em.getTransaction().commit();
em.close();
}
}

View File

@ -29,7 +29,6 @@ import javax.persistence.Table;
@Entity
@Table(name="CR_CRSE")
public class Course {
@Id
@GeneratedValue

View File

@ -42,7 +42,7 @@ public class EntityA implements Serializable {
private String name;
@OneToMany(fetch = FetchType.EAGER, mappedBy = "center", orphanRemoval = true, cascade = CascadeType.ALL)
@OrderColumn
@OrderColumn(name="POSITION")
private Set<EntityB> services = new LinkedHashSet<EntityB>();
public EntityA() {

View File

@ -22,6 +22,7 @@ import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
@ -47,6 +48,10 @@ public class EntityB {
@OrderColumn
private Set<EntityC> linacs;
@Column(name = "POSITION")
private int position;
public EntityB() {
}