public void testSerializeWithOneToMany_AddBidirectionalChildToDetached() throws Exception {
pm.setDetachAllOnCommit(true);
beginTxn();
HasOneToManyListJDO pojo = new HasOneToManyListJDO();
pojo.setVal("yar");
BidirectionalChildListJDO bidir = new BidirectionalChildListJDO();
bidir.setChildVal("yar2");
pojo.addBidirChild(bidir);
pm.makePersistent(pojo);
commitTxn();
pm.close();
pm = pmf.getPersistenceManager();
pojo = toBytesAndBack(pojo);
assertEquals("yar", pojo.getVal());
assertEquals(1, pojo.getBidirChildren().size());
BidirectionalChildListJDO bidir2 = new BidirectionalChildListJDO();
bidir2.setChildVal("yar3");
pojo.addBidirChild(bidir2);
bidir2.setParent(pojo);
beginTxn();
pojo = pm.makePersistent(pojo);
commitTxn();
Entity e = ds.get(KeyFactory.stringToKey(bidir2.getId()));
assertEquals(KeyFactory.stringToKey(pojo.getId()), e.getKey().getParent());
}