mirror of https://github.com/apache/openjpa.git
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:
parent
065dc9372f
commit
46bd717379
|
@ -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();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ import javax.persistence.Table;
|
|||
|
||||
@Entity
|
||||
@Table(name="CR_CRSE")
|
||||
|
||||
public class Course {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue