Package jodd.db.oom.tst

Examples of jodd.db.oom.tst.Girl


    // ---------------------------------------------------------------- girls

    DbOomQuery q = new DbOomQuery("select * from GIRL where ID=1");

    Girl girl = q.find(Girl.class);
    checkGirl1(girl);
    assertTrue(q.isActive());

    IdName idName = q.find(IdName.class);
    assertNotNull(idName);
View Full Code Here


    assertEquals("select bb.ID, bb.GIRL_ID, bb.NAME, bg.ID from BOY bb, GIRL bg where (bb.ID=:badBoy.ajdi) (bg.ID=:badGirl.fooid) or bb.ID=:p0", dbc.generateQuery());
  }

  @Test
  public void testCriteria2() {
    Girl girl = new Girl();
    girl.speciality = "piano";

    Girl girl_condition = new Girl();
    girl_condition.speciality = "swim";

    String tableRef = "ggg";

    DbSqlBuilder dsb = sql()._("update ").table(girl, tableRef).set(tableRef, girl)._("where ").
View Full Code Here

  public void testHint() {
    DbSession dbSession = new DbThreadSession(cp);

    // prepare data

    assertEquals(1, DbEntitySql.insert(new Girl(1, "Anna", "swim")).query().executeUpdate());
    assertEquals(1, DbEntitySql.insert(new Girl(2, "Sandra", "piano")).query().executeUpdate());
    assertEquals(1, DbEntitySql.insert(new Boy2(1, "John", 1)).query().executeUpdate());

    // select without hint

    DbOomQuery dbOomQuery = new DbOomQuery(q1);

    Object[] result = dbOomQuery.find(Boy2.class, Girl.class);

    Boy2 boy2 = (Boy2) result[0];
    assertEquals(1, boy2.id);
    assertEquals("John", boy2.name);
    assertEquals(1, boy2.girlId);
    assertNull(boy2.girl);

    Girl girl = (Girl) result[1];
    assertEquals(1, girl.id);

    // select with t-sql hint

    dbOomQuery = new DbOomQuery(q2);
View Full Code Here

    assertEquals("sanja", params.get("p0").getValue());
  }

  @Test
  public void testInsert() {
    Girl g = new Girl(1, "sanja", "c++");
    DbSqlBuilder b = DbEntitySql.insert(g);
    assertEquals("insert into GIRL (ID, NAME, SPECIALITY) values (:girl.id, :girl.name, :girl.speciality)", b.generateQuery());
    checkGirl(b);
  }
View Full Code Here

    checkGirl(b);
  }

  @Test
  public void testTruncate() {
    Girl g = new Girl(1, "sanja", "c++");
    assertEquals("delete from GIRL", DbEntitySql.truncate(g).generateQuery());
    assertEquals("delete from GIRL", DbEntitySql.truncate(Girl.class).generateQuery());
  }
View Full Code Here

    assertEquals("delete from GIRL", DbEntitySql.truncate(Girl.class).generateQuery());
  }

  @Test
  public void testUpdate() {
    Girl g = new Girl(1, "sanja", "c++");
    DbSqlBuilder b = DbEntitySql.update(g);
    assertEquals("update GIRL Girl_ set ID=:girl.id, NAME=:girl.name, SPECIALITY=:girl.speciality  where (1=1)",
        b.generateQuery());
    checkGirl(b);
View Full Code Here

    assertEquals("Anja", params.get("p0").getValue());
  }

  @Test
  public void testDelete() {
    Girl g = new Girl(1, "sanja", "c++");
    DbSqlBuilder b = DbEntitySql.delete(g);
    assertEquals("delete from GIRL where (GIRL.ID=:girl.id and GIRL.NAME=:girl.name and GIRL.SPECIALITY=:girl.speciality)",
        b.generateQuery());
    checkGirl(b);
View Full Code Here

    checkBadGirl4(b);
  }

  @Test
  public void testFrom() {
    Girl g = new Girl(1, "sanja", "c++");

    assertEquals("select Girl_.ID, Girl_.NAME, Girl_.SPECIALITY from GIRL Girl_ ",
        DbEntitySql.from(g).generateQuery());

    assertEquals("select BadGirl_.ID, BadGirl_.NAME, BadGirl_.SPECIALITY from GIRL BadGirl_ ",
View Full Code Here

        DbEntitySql.from(BadGirl.class, "ggg").generateQuery());
  }

  @Test
  public void testFind() {
    Girl g = new Girl(1, "sanja", "c++");
    DbSqlBuilder b = DbEntitySql.find(g);
    assertEquals("select Girl_.ID, Girl_.NAME, Girl_.SPECIALITY from GIRL Girl_ where (Girl_.ID=:girl.id and Girl_.NAME=:girl.name and Girl_.SPECIALITY=:girl.speciality)",
        b.generateQuery());
    checkGirl(b);
View Full Code Here

  }

  @Test
  public void testCount() {

    Girl g = new Girl(1, "sanja", "c++");
    DbSqlBuilder b = DbEntitySql.count(g);
    assertEquals("select count(*) from GIRL Girl_ where (Girl_.ID=:girl.id and Girl_.NAME=:girl.name and Girl_.SPECIALITY=:girl.speciality)",
        b.generateQuery());
    checkGirl(b);

View Full Code Here

TOP

Related Classes of jodd.db.oom.tst.Girl

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.