Package org.nutz.dao.sql

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


        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

    dao.execute(Sqls.create("DROP PROCEDURE IF EXISTS proc_pet_fetch"));

    dao.execute(Sqls.create("CREATE PROCEDURE proc_pet_fetch(IN nm varchar(1024))\nBEGIN\n\tSELECT * FROM t_pet where name=nm;\nEND"));
    Sql sql = Sqls.fetchEntity("CALL proc_pet_fetch(@nm)");
    sql.setEntity(dao.getEntity(Pet.class));
    sql.params().set("nm", "wendal");
    dao.execute(sql);
   
    Pet pet = sql.getObject(Pet.class);
    assertNotNull(pet);
    assertEquals("wendal", pet.getName());
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

            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

        // 这个仅仅测试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

        boolean hasBatchValues = batchValues != null && batchValues.size() > 0;
        if (hasBatchValues) {
            sqlObj = createSqlObj(sql, batchValues.get(0));
            for (Map<String, Object> params : batchValues) {
                Map<String, Object> newParams = paramProcess(params);
                sqlObj.params().putAll(newParams);
                sqlObj.addBatch();
            }
            dao.execute(sqlObj);
        } else {
            sqlObj = createSqlObj(sql, null);
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.