Package models.orphans.collections

Examples of models.orphans.collections.LevelOne


public class CollectionOrphan extends Controller {

    public static void create() {
        BaseModel base = new BaseModel();

        LevelOne levelOne = new LevelOne();
        levelOne.baseModel = base;

        LevelTwo levelTwo = new LevelTwo();
        levelTwo.levelOne = levelOne;
View Full Code Here


   
    @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));
View Full Code Here

    @Ignore("wait for full fix")
    @Test
    public void testTransientErrorAddingTogether() {
  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);
 
  levelOneB = new LevelOne();
  levelOneB.baseModel = bmB;
  bmB.levelOnes.add(levelOneB);

  bmA.save();
  bmB.save();
View Full Code Here

  bmA.save();
  commitAndClear();

  bmA = BaseModel.findById(bmA.id);

  LevelOne levelOneA = new LevelOne();
  levelOneA.baseModel = bmA;
  bmA.levelOnes.add(levelOneA);

  LevelTwo levelTwo = new LevelTwo();
  levelTwo.levelOne = levelOneA;
  levelOneA.levelTwos.add(levelTwo);

  LevelOne levelOneB = new LevelOne();
  levelOneB.baseModel = bmA;
  bmA.levelOnes.add(levelOneB);

  bmA.save();
  commitAndClear();

  bmA = BaseModel.findById(bmA.id);

  LevelOne removed = bmA.levelOnes.remove(0);
  bmA.save();

  JPA.em().flush(); // where bug actually occurs
    }
View Full Code Here

    public void testDuplicateError() {
  BaseModel bmA = new BaseModel();
  bmA.save();
  commit();

  LevelOne levelOneA = new LevelOne();
  levelOneA.baseModel = bmA;
  bmA.levelOnes.add(levelOneA);

  BaseModel bmB = new BaseModel();
  bmB.parent = levelOneA;
View Full Code Here

public class CollectionOrphan extends Controller {

    public static void create() {
        BaseModel base = new BaseModel();

        LevelOne levelOne = new LevelOne();
        levelOne.baseModel = base;

        LevelTwo levelTwo = new LevelTwo();
        levelTwo.levelOne = levelOne;
View Full Code Here

TOP

Related Classes of models.orphans.collections.LevelOne

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.