use of com.github.drinkjava2.jsqlbox.handler.EntityListHandler in project jSqlBox by drinkjava2.
the class HandlersTest method testSimpleCacheHandler.
@Test
public void testSimpleCacheHandler() {
for (int i = 0; i < 10; i++) {
// warm up
ctx.nQuery(new Wrap(new EntityListHandler(DemoUser.class), new SimpleCacheHandler()), "select u.** from DemoUser u where u.age>?", 0);
ctx.nQuery(new Wrap(new EntityListHandler(DemoUser.class)), "select u.** from DemoUser u where u.age>?", 0);
}
long start = System.currentTimeMillis();
for (int i = 0; i < 1000; i++) {
List<DemoUser> result = ctx.nQuery(new Wrap(new EntityListHandler(DemoUser.class), new SimpleCacheHandler()), "select u.** from DemoUser u where u.age>?", 0);
Assert.assertTrue(result.size() == 99);
}
long end = System.currentTimeMillis();
String timeused = "" + (end - start) / 1000 + "." + (end - start) % 1000;
System.out.println(String.format("%28s: %6s s", "With Cache", timeused));
start = System.currentTimeMillis();
for (int i = 0; i < 1000; i++) {
List<DemoUser> result = ctx.nQuery(new Wrap(new EntityListHandler(DemoUser.class)), "select u.** from DemoUser u where u.age>?", 0);
Assert.assertTrue(result.size() == 99);
}
end = System.currentTimeMillis();
timeused = "" + (end - start) / 1000 + "." + (end - start) % 1000;
System.out.println(String.format("%28s: %6s s", "No Cache", timeused));
}
use of com.github.drinkjava2.jsqlbox.handler.EntityListHandler in project jSqlBox by drinkjava2.
the class HandlersTest method testPaginHandler.
@Test
public void testPaginHandler() {
List<Map<String, Object>> result = ctx.nQuery(new Wrap(new EntitySqlMapListHandler(DemoUser.class), new PaginHandler(2, 5)), "select u.** from DemoUser u where u.age>?", 0);
Assert.assertTrue(result.size() == 5);
List<DemoUser> users = ctx.nQuery(new Wrap(new EntityListHandler(DemoUser.class), new PaginHandler(2, 5)), "select u.** from DemoUser u where u.age>?", 0);
Assert.assertTrue(users.size() == 5);
}
use of com.github.drinkjava2.jsqlbox.handler.EntityListHandler in project jSqlBox by drinkjava2.
the class EntityNetQueryTest method testEntityListHandler.
@Test
public void testEntityListHandler() {
System.out.println("==============testJoinFields================ ");
new User().put("id", "u1").put("userName", "user1").put("age", 10).insert();
new User().put("id", "u2").put("userName", "user2").put("age", 20).insert();
new User().put("id", "u3").put("userName", "user3").put("age", 30).insert();
List<User> setResult = ctx.nQuery(new EntityListHandler(User.class), "select u.** from usertb u where u.age>?", 10);
Assert.assertTrue(setResult.size() == 2);
}
use of com.github.drinkjava2.jsqlbox.handler.EntityListHandler in project jSqlBox by drinkjava2.
the class HandlersTest method testEntityListHandler.
@Test
public void testEntityListHandler() {
List<DemoUser> result = ctx.nQuery(new EntityListHandler(DemoUser.class), "select u.** from DemoUser u where u.age>?", 0);
Assert.assertTrue(result.size() == 99);
}
use of com.github.drinkjava2.jsqlbox.handler.EntityListHandler in project jSqlBox by drinkjava2.
the class HandlersTest method testHandlers.
@Test
public void testHandlers() {
List<DemoUser> result = ctx.nQuery(new Wrap(PrintSqlHandler.class, new EntityListHandler(DemoUser.class), new PaginHandler(1, 5), PrintSqlHandler.class), "select u.** from DemoUser u where u.age>?", 0);
Assert.assertTrue(result.size() == 5);
}
Aggregations