import com.google.appengine.datanucleus.test.jdo.Issue62Parent;
public class Issue62Test extends JDOTestCase {
public void testMultipleOneToOne() {
Issue62Parent parent;
Issue62Child child;
{
child = new Issue62Child();
parent = new Issue62Parent(child);
pm.makePersistent(parent);
pm.close();
}
// Create a second parent/child and next update the first child with the second parent
Issue62Parent parent2;
{
pm = pmf.getPersistenceManager();
parent2 = new Issue62Parent(new Issue62Child());
pm.makePersistent(parent2);
pm.close();
try {
pm = pmf.getPersistenceManager();
pm.currentTransaction().begin();
Issue62Child childToChangeParent = pm.getObjectById(Issue62Child.class, child.getId());
assertNotNull(childToChangeParent);
childToChangeParent.setParent(parent2);
parent2.setChild(childToChangeParent);
pm.currentTransaction().commit();
fail("Didn't throw exception on attempt to change parent");
} catch (JDOException jdoe) {
// Expected
}