Package org.nutz.dao.sql

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


        // 这个仅仅测试MySQL数据库
        if (isMySql) {
            dao.create(TableWithComment.class, true);
            // 表注释
            Sql findTableComment = Sqls.create(FIND_TABLE_COMMENT_MYSQL);
            findTableComment.params().set("tableName", "t_twc");
            findTableComment.setCallback(Sqls.callback.str());
            dao.execute(findTableComment);
            String tableComment = findTableComment.getString();
            Assert.assertTrue(!Strings.isBlank(tableComment) && "测试表".equals(tableComment));
            // 字段注释
View Full Code Here


            dao.execute(findTableComment);
            String tableComment = findTableComment.getString();
            Assert.assertTrue(!Strings.isBlank(tableComment) && "测试表".equals(tableComment));
            // 字段注释
            Sql findIdComment = Sqls.create(FIND_COLUMN_COMMENT_MYSQL);
            findIdComment.params().set("tableName", "t_twc").set("columnName", "id");
            findIdComment.setCallback(Sqls.callback.str());
            dao.execute(findIdComment);
            String idComment = findIdComment.getString();
            Assert.assertTrue(!Strings.isBlank(idComment) && "唯一主键".equals(idComment));
View Full Code Here

            dao.execute(findIdComment);
            String idComment = findIdComment.getString();
            Assert.assertTrue(!Strings.isBlank(idComment) && "唯一主键".equals(idComment));

            Sql findNameComment = Sqls.create(FIND_COLUMN_COMMENT_MYSQL);
            findNameComment.params().set("tableName", "t_twc").set("columnName", "nm");
            findNameComment.setCallback(Sqls.callback.str());
            dao.execute(findNameComment);
            String nameComment = findNameComment.getString();
            Assert.assertTrue(!Strings.isBlank(nameComment) && "name".equals(nameComment));
View Full Code Here

            dao.execute(findNameComment);
            String nameComment = findNameComment.getString();
            Assert.assertTrue(!Strings.isBlank(nameComment) && "name".equals(nameComment));

            Sql findNumComment = Sqls.create(FIND_COLUMN_COMMENT_MYSQL);
            findNumComment.params().set("tableName", "t_twc").set("columnName", "num");
            findNumComment.setCallback(Sqls.callback.str());
            dao.execute(findNumComment);
            String numComment = findNumComment.getString();
            Assert.assertTrue(Strings.isBlank(numComment));
        }
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

    @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

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.