Package models

Examples of models.World


  public static void setup() {
   
    //JPAPlugin plugin = play.Play.plugin(JPAPlugin.class);
    //plugin.startTx(true);
    World w = new World() ;
    w.getPersistenceManager().beginTransaction();

    // clean out the old
    World.deleteAll();
    System.out.println("DELETED");
    // in with the new
    List<World> worlds = new ArrayList<World>() ;
    for (long i = 0; i <= TEST_DATABASE_ROWS; i++) {
      int randomNumber = random.nextInt(TEST_DATABASE_ROWS) + 1;
      worlds.add(new World(i, randomNumber));
      if (i % 100 == 0) {
       

        World.batch().insert(worlds) ;
        System.out.println("FLUSHED : " + i + "/" + TEST_DATABASE_ROWS);
        worlds.clear() ;
      }
    }
    System.out.println("ADDED");
    //plugin.closeTx(false);
    w.getPersistenceManager().commitTransaction();

  }
View Full Code Here


    Job<List<World>> job = new Job<List<World>>() {
      public java.util.List<World> doJobWithResult() throws Exception {
        for (int i = 0; i < queryCount; ++i) {
          Long id = Long
              .valueOf(random.nextInt(TEST_DATABASE_ROWS) + 1);
          World result = World.findById(id);
          worlds.add(result);
        }
        return worlds;
      };
    };
View Full Code Here

    if (queries == 0)
      queries = 1;
    final List<World> worlds = new ArrayList<World>();
    for (int i = 0; i < queries; ++i) {
      Long id = Long.valueOf(random.nextInt(TEST_DATABASE_ROWS) + 1);
      World result = World.findById(id);
      worlds.add(result);
    }
    renderJSON(worlds);
  }
View Full Code Here

            public List<World> apply() throws Throwable {
                Random random = ThreadLocalRandom.current();
                List<World> worlds = new ArrayList<World>(n);
                for (int i = 0; i < n; ++i) {
                    long randomId = random.nextInt(TEST_DATABASE_ROWS) + 1;
                    World world = World.findById(randomId);
                    worlds.add(world);
                }
                return worlds;
            }
        }, dbEc);
View Full Code Here

            public List<World> apply() {
                Random random = ThreadLocalRandom.current();
                List<World> worlds = new ArrayList<World>(n);
                for (int i = 0; i < n; ++i) {
                    long randomId = random.nextInt(TEST_DATABASE_ROWS) + 1;
                    World world = World.find.byId(randomId);
                    worlds.add(world);
                }
                return worlds;
            }
        }, dbEc);
View Full Code Here

            public List<World> apply() throws Throwable {
                Random random = ThreadLocalRandom.current();
                List<World> worlds = new ArrayList<World>(n);
                for (int i = 0; i < n; ++i) {
                    long randomId = random.nextInt(TEST_DATABASE_ROWS) + 1;
                    World world = World.findById(randomId);
                    worlds.add(world);
                }
                return worlds;
            }
        }, dbEc);
View Full Code Here

    if (queries == 0)
      queries = 1;
    final List<World> worlds = new ArrayList<World>();
    for (int i = 0; i < queries; ++i) {
      Long id = Long.valueOf(random.nextInt(TEST_DATABASE_ROWS) + 1);
      World result = World.findById(id);
      worlds.add(result);
    }
    renderJSON(worlds);
  }
View Full Code Here

    World.deleteAll();
    System.out.println("DELETED");
    // in with the new
    for (long i = 0; i <= TEST_DATABASE_ROWS; i++) {
      int randomNumber = random.nextInt(TEST_DATABASE_ROWS) + 1;
      new World(i, randomNumber).save();
      if (i % 100 == 0) {

        World.em().flush();
        World.em().clear();
        System.out.println("FLUSHED : " + i + "/" + TEST_DATABASE_ROWS);
View Full Code Here

    for (int i = 0; i < queryCount; ++i) {
      final Long id = Long
          .valueOf(random.nextInt(TEST_DATABASE_ROWS) + 1);
      Job<World> job = new Job<World>() {
        public World doJobWithResult() throws Exception {
          World result = World.findById(id);
          return result;
        };
      };
      promises.add(job.now());
    }
View Full Code Here

    Job<List<World>> job = new Job<List<World>>() {
      public java.util.List<World> doJobWithResult() throws Exception {
        for (int i = 0; i < queryCount; ++i) {
          Long id = Long
              .valueOf(random.nextInt(TEST_DATABASE_ROWS) + 1);
          World result = World.findById(id);
          worlds.add(result);
        }
        return worlds;
      };
    };
View Full Code Here

TOP

Related Classes of models.World

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.