Package yalp.db.Model

Examples of yalp.db.Model.Factory


        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


      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

TOP

Related Classes of yalp.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.