Search in sources :

Example 1 with EntityListHandler

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));
}
Also used : Wrap(com.github.drinkjava2.jdbpro.handler.Wrap) SimpleCacheHandler(com.github.drinkjava2.jdbpro.handler.SimpleCacheHandler) EntityListHandler(com.github.drinkjava2.jsqlbox.handler.EntityListHandler) Test(org.junit.Test)

Example 2 with EntityListHandler

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);
}
Also used : PaginHandler(com.github.drinkjava2.jsqlbox.handler.PaginHandler) Wrap(com.github.drinkjava2.jdbpro.handler.Wrap) EntityListHandler(com.github.drinkjava2.jsqlbox.handler.EntityListHandler) Map(java.util.Map) EntitySqlMapListHandler(com.github.drinkjava2.jsqlbox.handler.EntitySqlMapListHandler) Test(org.junit.Test)

Example 3 with EntityListHandler

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);
}
Also used : User(com.github.drinkjava2.functionstest.entitynet.entities.User) EntityListHandler(com.github.drinkjava2.jsqlbox.handler.EntityListHandler) Test(org.junit.Test)

Example 4 with EntityListHandler

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);
}
Also used : EntityListHandler(com.github.drinkjava2.jsqlbox.handler.EntityListHandler) Test(org.junit.Test)

Example 5 with EntityListHandler

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);
}
Also used : PaginHandler(com.github.drinkjava2.jsqlbox.handler.PaginHandler) Wrap(com.github.drinkjava2.jdbpro.handler.Wrap) EntityListHandler(com.github.drinkjava2.jsqlbox.handler.EntityListHandler) PrintSqlHandler(com.github.drinkjava2.jdbpro.handler.PrintSqlHandler) Test(org.junit.Test)

Aggregations

EntityListHandler (com.github.drinkjava2.jsqlbox.handler.EntityListHandler)6 Test (org.junit.Test)5 Wrap (com.github.drinkjava2.jdbpro.handler.Wrap)3 PaginHandler (com.github.drinkjava2.jsqlbox.handler.PaginHandler)2 User (com.github.drinkjava2.functionstest.entitynet.entities.User)1 PrintSqlHandler (com.github.drinkjava2.jdbpro.handler.PrintSqlHandler)1 SimpleCacheHandler (com.github.drinkjava2.jdbpro.handler.SimpleCacheHandler)1 PreparedSQL (com.github.drinkjava2.jdbpro.inline.PreparedSQL)1 EntitySqlMapListHandler (com.github.drinkjava2.jsqlbox.handler.EntitySqlMapListHandler)1 Method (java.lang.reflect.Method)1 Map (java.util.Map)1 ResultSetHandler (org.apache.commons.dbutils.ResultSetHandler)1