Package org.nutz.dao.sql

Examples of org.nutz.dao.sql.Sql.params()


  @Test
  public void test_parse_whole_directory() {
    SqlManager sqls = new FileSqlManager("org/nutz/dao/test/sqls/dir");
    assertTrue(sqls.count() > 0);
    Sql sql = sqls.create(".abc.update");
    sql.params().set("name", "ABC");
    sql.params().set("id", 16);
    assertEquals("UPDATE t_abc SET name='ABC' WHERE id=16;", sql.toString());
  }
}
View Full Code Here


  public void test_parse_whole_directory() {
    SqlManager sqls = new FileSqlManager("org/nutz/dao/test/sqls/dir");
    assertTrue(sqls.count() > 0);
    Sql sql = sqls.create(".abc.update");
    sql.params().set("name", "ABC");
    sql.params().set("id", 16);
    assertEquals("UPDATE t_abc SET name='ABC' WHERE id=16;", sql.toString());
  }
}
View Full Code Here

      pojos.initPet();
      dao.insert(Pet.create(8));
      assertEquals(8, dao.count(Pet.class));
      Sql sql = Sqls.queryEntity("SELECT * FROM t_pet $condition LIMIT @off,@size ");
      sql.setEntity(dao.getEntity(Pet.class));
      sql.params().set("off", 2).set("size", 2);
      sql.setCondition(Cnd.orderBy().asc("name"));
      dao.execute(sql);
      List<Pet> pets = sql.getList(Pet.class);
      assertEquals(2, pets.size());
      assertEquals("pet_02", pets.get(0).getName());
View Full Code Here

    int platoonId = 23;
    try {
      pojos.initPlatoon(platoonId);
      Sql sql = dao.sqls().create("tank.insert");
      sql.vars().set("id", platoonId);
      sql.params().set("code", "T1").set("weight", 12);
      dao.execute(sql);

      sql = dao.sqls().create("tank.insert");
      sql.vars().set("id", platoonId);
      sql.params().set("code", "T2").set("weight", 13);
View Full Code Here

      sql.params().set("code", "T1").set("weight", 12);
      dao.execute(sql);

      sql = dao.sqls().create("tank.insert");
      sql.vars().set("id", platoonId);
      sql.params().set("code", "T2").set("weight", 13);
      dao.execute(sql);

      sql = dao.sqls().create("tank.insert");
      sql.vars().set("id", platoonId);
      sql.params().set("code", "T3").set("weight", 14);
View Full Code Here

      sql.params().set("code", "T2").set("weight", 13);
      dao.execute(sql);

      sql = dao.sqls().create("tank.insert");
      sql.vars().set("id", platoonId);
      sql.params().set("code", "T3").set("weight", 14);
      dao.execute(sql);

      sql = dao.sqls().create("tank.insert");
      sql.vars().set("id", platoonId);
      sql.params().set("code", "T4").set("weight", 15);
View Full Code Here

      sql.params().set("code", "T3").set("weight", 14);
      dao.execute(sql);

      sql = dao.sqls().create("tank.insert");
      sql.vars().set("id", platoonId);
      sql.params().set("code", "T4").set("weight", 15);
      dao.execute(sql);

      TableName.run(platoonId, new Atom() {
        public void run() {
          assertEquals(4, dao.count(Tank.class));
View Full Code Here

  @Test
  public void test_statice_null_field() {
    pojos.init();
    Sql sql = Sqls.create("INSERT INTO dao_country (name,detail) VALUES(@name,@detail)");
    sql.params().set("name", "ABC").set("detail", "haha");
    dao.execute(sql);
    assertEquals(1, dao.count("dao_country"));

    sql = Sqls.create("UPDATE dao_country SET detail=@detail WHERE name=@name");
    sql.params().set("name", "ABC").set("detail", null);
View Full Code Here

    sql.params().set("name", "ABC").set("detail", "haha");
    dao.execute(sql);
    assertEquals(1, dao.count("dao_country"));

    sql = Sqls.create("UPDATE dao_country SET detail=@detail WHERE name=@name");
    sql.params().set("name", "ABC").set("detail", null);
    dao.execute(sql);
    Country c = dao.fetch(Country.class, "ABC");
    assertNull(c.getDetail());
  }
}
View Full Code Here

        boolean isMySql = dao.meta().isMySql();
        // 这个仅仅测试MySQL数据库
        if (isMySql) {
            dao.create(TableWithTimestampInMySql.class, true);
            Sql descTable = Sqls.create(DESC_TABLE_SQL);
            descTable.params().set("tableName", "t_ts");
            descTable.setCallback(new SqlCallback() {
                public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                    boolean ts1 = false;
                    boolean ts2 = false;
                    boolean ts3 = false;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.