Package models.orphans.collections

Examples of models.orphans.collections.BaseModel


import play.mvc.Controller;

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;

        levelOne.levelTwos.add(levelTwo);

        base.levelOnes.add(levelOne);
        base.save();
       
        renderText(base.id);
    }
View Full Code Here


       
        renderText(base.id);
    }

    public static void update(Long id) {
        BaseModel base = BaseModel.findById(id);
        base.levelOnes.remove(0);
        base.save();
    }
View Full Code Here

  assertEquals("There should not be any meals left", 0, Meal.count());
    }
   
    @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();
  assertEquals("We must have 2 LevelOne", 2L, LevelOne.count("baseModel = ?1 OR baseModel = ?2", bmA, bmB));
    }
View Full Code Here

  assertEquals("We must have 2 LevelOne", 2L, LevelOne.count("baseModel = ?1 OR baseModel = ?2", bmA, bmB));
    }
   
    @Test
    public void testCollectionOwnerError() {
  BaseModel bmA = new BaseModel();
  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

  JPA.em().flush(); // where bug actually occurs
    }

    @Test
    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;
  levelOneA.children.add(bmB);

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

import yalp.mvc.Controller;

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;

        levelOne.levelTwos.add(levelTwo);

        base.levelOnes.add(levelOne);
        base.save();
       
        renderText(base.id);
    }
View Full Code Here

       
        renderText(base.id);
    }

    public static void update(Long id) {
        BaseModel base = BaseModel.findById(id);
        base.levelOnes.remove(0);
        base.save();
    }
View Full Code Here

TOP

Related Classes of models.orphans.collections.BaseModel

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.