OPENJPA-2335 review test case and update checks

git-svn-id: https://svn.apache.org/repos/asf/openjpa/branches/2.3.x@1540371 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Struberg 2013-11-09 19:26:31 +00:00
parent fe7cfaef9d
commit 979d8f24e9
3 changed files with 15 additions and 11 deletions

View File

@ -327,8 +327,7 @@ public abstract class RelationToManyInverseKeyFieldStrategy
if (sm != null && sm.isDeleted())
sm = null;
writeable = io.isAnyUpdatable(fk, sm == null);
orderWriteable = field.getOrderColumnIO().isUpdatable
(order, sm == null);
orderWriteable = field.getOrderColumnIO().isUpdatable(order, sm == null);
action = Row.ACTION_UPDATE;
}
if (!writeable && !orderWriteable)
@ -345,8 +344,11 @@ public abstract class RelationToManyInverseKeyFieldStrategy
// update the inverse pointer with our oid value
if (writeable)
row.setForeignKey(fk, io, sm);
if (orderWriteable)
if (orderWriteable) {
// set the OrderColumn value
row.setInt(order, idx);
}
}
public Object toDataStoreValue(Object val, JDBCStore store) {

View File

@ -67,19 +67,18 @@ public class TestOpenJPA2330 extends SingleEMFTestCase {
EntityB b1 = new EntityB(a);
b1.setName("b1");
a.getBs().add(b1);
EntityB b2 = new EntityB(a);
b2.setName("b2");
a.getBs().add(b2);
EntityB b3 = new EntityB(a);
b3.setName("b3");
a.getBs().add(b3);
EntityB b4 = new EntityB(a);
b4.setName("b4");
a.getBs().add(b1);
a.getBs().add(b2);
a.getBs().add(b3);
a.getBs().add(b4);
em.persist(a);
@ -95,6 +94,13 @@ public class TestOpenJPA2330 extends SingleEMFTestCase {
Assert.assertNotNull(a2.getBs());
Assert.assertEquals(4, a2.getBs().size());
Iterator<EntityB> it = a2.getBs().iterator();
for (int i = 1; i <= 4; i++) {
EntityB entityB = it.next();
Assert.assertEquals("b" + i, entityB.getName());
}
em.getTransaction().commit();
em.close();
}

View File

@ -48,10 +48,6 @@ public class EntityB {
@OrderColumn
private Set<EntityC> linacs;
@Column(name = "POSITION")
private int position;
public EntityB() {
}