Package jodd.db.oom.tst

Examples of jodd.db.oom.tst.Boy


    st = sql("$T{BadBoy b}");
    assertEquals("BOY b", st.generateQuery());

    // 2
    st = sql("$T{b}").use("b", new Boy());
    assertEquals("BOY", st.generateQuery());
    st = sql("$T{b b}").use("b", new Boy());
    assertEquals("BOY b", st.generateQuery());

    st = sql("$T{b}").use("b", new BadBoy());
    assertEquals("BOY", st.generateQuery());
View Full Code Here


    st = sql("$T{BadBoy} | $C{BadBoy.ajdi} | $C{BadBoy.*} | $C{BadBoy.+}");
    assertEquals("BOY | BOY.ID | BOY.ID, BOY.GIRL_ID, BOY.NAME | BOY.ID", st.generateQuery());

    // 2
    st = sql("$T{b b} | $C{b.id}").use("b", new Boy());
    assertEquals("BOY b | b.ID", st.generateQuery());

    st = sql("$T{b bb} | $C{bb.id} | $C{bb.*}").use("b", new Boy());
    assertEquals("BOY bb | bb.ID | bb.GIRL_ID, bb.ID, bb.NAME", st.generateQuery());

    st = sql("$T{b bb} | $C{bb.ajdi} | $C{bb.*} | $C{bb.+}").use("b", new BadBoy());
    assertEquals("BOY bb | bb.ID | bb.ID, bb.GIRL_ID, bb.NAME | bb.ID", st.generateQuery());

View Full Code Here

  @Test
  public void testMatch() {
    DbSqlBuilder st;

    Boy boy = new Boy();
    boy.id = 1;
    boy.girlId = 3;
    st = sql("$T{boy boy} where $M{boy=boy}").use("boy", boy);
    assertEquals("BOY boy where (boy.GIRL_ID=:boy.girlId and boy.ID=:boy.id)", st.generateQuery());
    Map<String, ParameterValue> map = st.getQueryParameters();
View Full Code Here

    dbSession = new DbThreadSession(cp);

    assertEquals(1, DbEntitySql.insert(new Girl2(1, "Anna", "swim")).query().executeUpdate());
    assertEquals(1, DbEntitySql.insert(new Girl2(2, "Sandra", "piano")).query().executeUpdate());
    assertEquals(1, DbEntitySql.insert(new Girl2(3, "Emma", "nothing")).query().executeUpdate());
    assertEquals(1, DbEntitySql.insert(new Boy(1, "Johny", 2)).query().executeUpdate());
    assertEquals(1, DbEntitySql.insert(new Boy(2, "Marco", 2)).query().executeUpdate());
    assertEquals(1, DbEntitySql.insert(new Boy(3, "Hugo", 1)).query().executeUpdate());
  }
View Full Code Here

    assertTrue(girl1.equals(girl2));
    assertTrue(girl1 == girl2);
    assertFalse(girl3 == girl1);

    Boy boy1 = (Boy) result.get(0)[1];
    Boy boy2 = (Boy) result.get(1)[1];
    Boy boy3 = (Boy) result.get(2)[1];

    assertTrue(boy1.id != boy2.id);
    assertFalse(boy1 == boy2);
    assertFalse(boy2 == boy3);
View Full Code Here

    assertEquals("Emma", girl0.name);
    assertTrue(girl1.equals(girl2));
    assertTrue(girl1 == girl2);
    assertFalse(girl3 == girl1);

    Boy boy0 = (Boy) result.get(0)[1];
    Boy boy1 = (Boy) result.get(1)[1];
    Boy boy2 = (Boy) result.get(2)[1];
    Boy boy3 = (Boy) result.get(3)[1];

    assertNull(boy0);
    assertTrue(boy1.id != boy2.id);
    assertFalse(boy1 == boy2);
    assertFalse(boy2 == boy3);
View Full Code Here

    assertEquals("BOY.ID BOY", sql().ref("Boy.id")._(" ").table("Boy", null).aliasColumnsAs(COLUMN_CODE).generateQuery());
  }

  @Test
  public void testInsert() {
    Boy b = new Boy();

    DbSqlBuilder dbc = sql().insert("Boy", b);
    assertEquals("insert into BOY (GIRL_ID, ID) values (:boy.girlId, :boy.id)", dbc.generateQuery());
    assertEquals(2, dbc.getQueryParameters().size());
    assertEquals(Integer.valueOf(0), dbc.getQueryParameters().get("boy.girlId").getValue());
View Full Code Here

  }

  @Test
  @SuppressWarnings({"unchecked"})
  public void testValue() {
    Boy b = new Boy();
    DbSqlBuilder dbc = new DbSqlBuilder();
    assertEquals(":zzz", dbc.value("zzz", Integer.valueOf(b.girlId)).generateQuery());
    assertEquals(1, dbc.getQueryParameters().size());
    assertEquals(Integer.valueOf(0), dbc.getQueryParameters().get("zzz").getValue());
View Full Code Here

  }

  @Test
  public void testUpdateSet() {
    Boy b = new Boy();
    b.id = 1;
    b.girlId = 2;

    DbSqlBuilder dbc = sql().set("b", b).table("Boy", "b");
    assertEquals("set GIRL_ID=:boy.girlId, ID=:boy.id BOY b", dbc.generateQuery());
View Full Code Here

  }

  @Test
  public void testWhere() {
    {
      Boy b = new Boy();
      b.id = 1;
      b.girlId = 2;
      DbSqlBuilder dbc = sql().match("Boy", b)._(" ").table(b, null);
      assertEquals("(BOY.GIRL_ID=:boy.girlId and BOY.ID=:boy.id) BOY", dbc.generateQuery());
      dbc = sql().match("b", b)._(" ").table(b, "b");
View Full Code Here

TOP

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

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.