Search in sources :

Example 11 with Address

use of com.github.drinkjava2.functionstest.entitynet.entities.Address in project jSqlBox by drinkjava2.

the class UsuageAndSpeedTest method nXxxStyle.

@Test
public void nXxxStyle() {
    SqlBoxContext ctx = new SqlBoxContext(dataSource);
    for (int i = 0; i < REPEAT_TIMES; i++) {
        ctx.nExecute("insert into users (name,address) values(?,?)", "Sam", "Canada");
        ctx.nExecute("update users set name=?, address=?", "Tom", "China");
        Assert.assertEquals(1L, ctx.nQueryForObject("select count(*) from users where name=? and address=?", "Tom", "China"));
        ctx.nExecute("delete from users where name=? or address=?", "Tom", "China");
    }
}
Also used : SqlBoxContext(com.github.drinkjava2.jsqlbox.SqlBoxContext) Test(org.junit.Test)

Example 12 with Address

use of com.github.drinkjava2.functionstest.entitynet.entities.Address in project jSqlBox by drinkjava2.

the class UsuageAndSpeedTest method dbUtilsNoConnMethod.

@Test
public void dbUtilsNoConnMethod() {
    SqlBoxContext ctx = new SqlBoxContext(dataSource);
    for (int i = 0; i < REPEAT_TIMES; i++) {
        try {
            ctx.execute("insert into users (name,address) values(?,?)", "Sam", "Canada");
            ctx.execute("update users set name=?, address=?", "Tom", "China");
            Assert.assertEquals(1L, ctx.queryForObject("select count(*) from users where name=? and address=?", "Tom", "China"));
            ctx.execute("delete from users where name=? or address=?", "Tom", "China");
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
Also used : SQLException(java.sql.SQLException) SqlBoxContext(com.github.drinkjava2.jsqlbox.SqlBoxContext) Test(org.junit.Test)

Example 13 with Address

use of com.github.drinkjava2.functionstest.entitynet.entities.Address in project jSqlBox by drinkjava2.

the class UsuageAndSpeedTest method tXxxStyle.

@Test
public void tXxxStyle() {
    SqlBoxContext ctx2 = new SqlBoxContext(dataSource);
    Map<String, Object> params = new HashMap<String, Object>();
    for (int i = 0; i < REPEAT_TIMES; i++) {
        UserAR sam = new UserAR("Sam", "Canada");
        UserAR tom = new UserAR("Tom", "China");
        params.put("user", sam);
        ctx2.tExecute("insert into users (name, address) values(#{user.name},:user.address)", params);
        params.put("user", tom);
        ctx2.tExecute("update users set name=#{user.name}, address=:user.address", params);
        params.clear();
        params.put("name", "Tom");
        params.put("addr", "China");
        Assert.assertEquals(1L, ctx2.tQueryForObject("select count(*) from users where name=#{name} and address=:addr", params));
        params.put("u", tom);
        ctx2.tExecute("delete from users where name=:u.name or address=#{u.address}", params);
    }
}
Also used : HashMap(java.util.HashMap) SqlBoxContext(com.github.drinkjava2.jsqlbox.SqlBoxContext) Test(org.junit.Test)

Example 14 with Address

use of com.github.drinkjava2.functionstest.entitynet.entities.Address in project jSqlBox by drinkjava2.

the class UsuageAndSpeedTest method iXxxStyle2.

@Test
public void iXxxStyle2() {
    SqlBoxContext ctx = new SqlBoxContext(dataSource);
    for (int i = 0; i < REPEAT_TIMES; i++) {
        // 
        ctx.iExecute(// 
        "insert into ", // 
        UserAR.USER, // 
        " ( ", // 
        UserAR.NAME, // 
        ",", // 
        param0("Sam"), // 
        UserAR.ADDRESS, // 
        " ", // 
        param("Canada"), ") ", valuesQuesions());
        param0("Tom", "China");
        ctx.iExecute("update users set name=?,address=?");
        Assert.assertEquals(1L, ctx.iQueryForObject("select count(*) from users where name=? and address=?" + param0("Tom", "China")));
        ctx.iExecute("delete from users where name=", question0("Tom"), " or address=", question("China"));
    }
}
Also used : SqlBoxContext(com.github.drinkjava2.jsqlbox.SqlBoxContext) Test(org.junit.Test)

Example 15 with Address

use of com.github.drinkjava2.functionstest.entitynet.entities.Address in project jSqlBox by drinkjava2.

the class UsuageAndSpeedTest method iXxxStyle.

@Test
public void iXxxStyle() {
    SqlBoxContext ctx = new SqlBoxContext(dataSource);
    for (int i = 0; i < REPEAT_TIMES; i++) {
        // 
        ctx.iExecute(// 
        "insert into users (", // 
        " name ,", // 
        param0("Sam"), // 
        " address ", // 
        param("Canada"), ") ", valuesQuesions());
        param0("Tom", "China");
        ctx.iExecute("update users set name=?,address=?");
        Assert.assertEquals(1L, ctx.iQueryForObject("select count(*) from users where name=? and address=?" + param0("Tom", "China")));
        ctx.iExecute("delete from users where name=", question0("Tom"), " or address=", question("China"));
    }
}
Also used : SqlBoxContext(com.github.drinkjava2.jsqlbox.SqlBoxContext) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)14 SqlBoxContext (com.github.drinkjava2.jsqlbox.SqlBoxContext)8 TableModel (com.github.drinkjava2.jdialects.model.TableModel)4 User (com.github.drinkjava2.functionstest.entitynet.entities.User)2 SQLException (java.sql.SQLException)2 Address (com.github.drinkjava2.functionstest.entitynet.entities.Address)1 Email (com.github.drinkjava2.functionstest.entitynet.entities.Email)1 Privilege (com.github.drinkjava2.functionstest.entitynet.entities.Privilege)1 Role (com.github.drinkjava2.functionstest.entitynet.entities.Role)1 RolePrivilege (com.github.drinkjava2.functionstest.entitynet.entities.RolePrivilege)1 UserRole (com.github.drinkjava2.functionstest.entitynet.entities.UserRole)1 ColumnModel (com.github.drinkjava2.jdialects.model.ColumnModel)1 Table (com.github.drinkjava2.jdialects.model.Table)1 SqlBoxContextConfig (com.github.drinkjava2.jsqlbox.SqlBoxContextConfig)1 Connection (java.sql.Connection)1 HashMap (java.util.HashMap)1