Package play.db.Model

Examples of play.db.Model.Factory


      // Proceed only if searchable
      if (!MappingUtil.isSearchable(modelClass)) {
        continue;
      }

      final Factory factory = Model.Manager.factoryFor(modelClass);
      final long count = factory.count(null, null, null);

      // Defensively avoid overflow leading to infinite loop below
      if (count > Integer.MAX_VALUE) {
        throw new RuntimeException(String.format("Number of entities %s to index is too large (%d)", modelClass, count));
      }

      Logger.info("Reindexing %s entities of type %s", count, modelClass);

      long offset = 0;
      // loop over pages
      while (offset < count) {
        final List results = factory.fetch((int) offset, PAGE_SIZE, null, null, null, null, null);
        // loop over individual entities within one page
        for (final Object o : results) {
          ElasticSearch.index((Model) o, deliveryMode);
        }
        offset += PAGE_SIZE;
View Full Code Here


      Fixtures.delete(CompositeIdEntity.class, CompositeIdForeignA.class, CompositeIdForeignB.class);
    }

    @Test
    public void testGetId() {
      Factory factory = Model.Manager.factoryFor(CompositeIdEntity.class);
      assertNotNull(factory);
      CompositeIdForeignA a = new CompositeIdForeignA();
      a.save();
      CompositeIdForeignB b = new CompositeIdForeignB();
      b.save();
      CompositeIdEntity e = new CompositeIdEntity();
      e.compositeIdForeignA = a;
      e.compositeIdForeignB = b;
      e.save();
     
    // let's get its key
      Object id = factory.keyValue(e);
      assertNotNull(id);
      assertTrue(id instanceof CompositeIdPk);
      CompositeIdPk pk = (CompositeIdPk) id;
      assertEquals(a.id, pk.getCompositeIdForeignA());
      assertEquals(b.id, pk.getCompositeIdForeignB());
View Full Code Here

      assertEquals(b.id, pk.getCompositeIdForeignB());
    }

    @Test
    public void testBindById() {
      Factory factory = Model.Manager.factoryFor(CompositeIdEntity.class);
      assertNotNull(factory);
      CompositeIdForeignA a = new CompositeIdForeignA();
      a.save();
      CompositeIdForeignB b = new CompositeIdForeignB();
      b.save();
      CompositeIdEntity e = new CompositeIdEntity();
      e.compositeIdForeignA = a;
      e.compositeIdForeignB = b;
      e.save();

    // let's get its key
      Object id = factory.keyValue(e);
      Model eDB = factory.findById(id);
      assertEquals(e, eDB);
    }
View Full Code Here

        public Model findById(String id) throws Exception {
            if (id == null) {
                return null;
            }

            Factory factory =  Model.Manager.factoryFor(entityClass);
            Object boundId = Binder.directBind(id, factory.keyType());
            return factory.findById(boundId);
        }
View Full Code Here

TOP

Related Classes of play.db.Model.Factory

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.