use of com.github.drinkjava2.jsqlbox.SqlBoxContext in project jSqlBox by drinkjava2.
the class UsuageAndSpeedTest method sqlMapperUseText.
@Test
public void sqlMapperUseText() {
SqlBoxContext ctx = new SqlBoxContext(dataSource);
// use global default context
SqlBoxContext.setGlobalSqlBoxContext(ctx);
TextedUser user = new TextedUser();
for (int i = 0; i < REPEAT_TIMES; i++) {
user.insertOneUser("Sam", "Canada");
user.ctx().nUpdate(user.updateAllUserPreSql("Tom", "China"));
// List<Map<String, Object>> users = user.selectUsersByText("Tom", "China");
// Assert.assertEquals(1, users.size());
List<TextedUser> users2 = user.selectUsersByText2("Tom", "China");
Assert.assertEquals(1, users2.size());
user.deleteUsers("Tom", "China");
Assert.assertEquals(0, user.ctx().nQueryForLongValue("select count(*) from users"));
}
}
use of com.github.drinkjava2.jsqlbox.SqlBoxContext 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"));
}
}
use of com.github.drinkjava2.jsqlbox.SqlBoxContext in project jSqlBox by drinkjava2.
the class UsuageAndSpeedTest method abstractSqlMapperUseText.
@Test
public void abstractSqlMapperUseText() {
SqlBoxContext ctx = new SqlBoxContext(dataSource);
// use global default context
SqlBoxContext.setGlobalSqlBoxContext(ctx);
AbstractUser user = ActiveRecord.create(AbstractUser.class);
for (int i = 0; i < REPEAT_TIMES; i++) {
user.insertOneUser("Sam", "Canada");
user.ctx().nUpdate(user.updateUserPreparedSQL("Tom", "China"));
// List<Map<String, Object>> users = user.selectUserListMap("Tom", "China");
// Assert.assertEquals(1, users.size());
List<AbstractUser> users2 = user.selectAbstractUserList("Tom", "China");
Assert.assertEquals(1, users2.size());
user.deleteUsers("Tom", "China");
Assert.assertEquals(0, user.ctx().nQueryForLongValue("select count(*) from users"));
}
}
use of com.github.drinkjava2.jsqlbox.SqlBoxContext in project jSqlBox by drinkjava2.
the class UsuageAndSpeedTest method activeRecordStyle.
@Test
public void activeRecordStyle() {
SqlBoxContext ctx = new SqlBoxContext(dataSource);
UserAR user = new UserAR();
// Use ctx as SqlBoxContext
user.useContext(ctx);
for (int i = 0; i < REPEAT_TIMES; i++) {
user.setName("Sam");
user.setAddress("Canada");
user.insert();
user.setAddress("China");
user.update();
UserAR user2 = user.load("Sam");
user2.delete();
}
}
use of com.github.drinkjava2.jsqlbox.SqlBoxContext 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"));
}
}
Aggregations