@Test
public void testTransientErrorAddingSeparatly() {
BaseModel bmA = new BaseModel();
LevelOne levelOneA = new LevelOne();
levelOneA.baseModel = bmA;
bmA.levelOnes.add(levelOneA);
BaseModel bmB = new BaseModel();
LevelOne levelOneB = new LevelOne();
levelOneB.baseModel = bmB;
bmB.levelOnes.add(levelOneB);
bmA.save();
bmB.save();
assertEquals("We must have 2 LevelOne", 2L, LevelOne.count("baseModel = ?1 OR baseModel = ?2", bmA, bmB));
// now clear them out
bmA.levelOnes.clear();
bmB.levelOnes.clear();
bmA.save();
bmB.save();
assertEquals("We must have 0 LevelOne", 0L, LevelOne.count("baseModel = ?1 OR baseModel = ?2", bmA, bmB));
// now add new ones
levelOneA = new LevelOne();
levelOneA.baseModel = bmA;
bmA.levelOnes.add(levelOneA);
bmA.save();
levelOneB = new LevelOne();
levelOneB.baseModel = bmB;
bmB.levelOnes.add(levelOneB);
bmB.save();
assertEquals("We must have 2 LevelOne", 2L, LevelOne.count("baseModel = ?1 OR baseModel = ?2", bmA, bmB));