Package org.nutz.dao.sql

Examples of org.nutz.dao.sql.SqlCallback


  public void test_query_without_entity() {
    pojos.initPet();
    dao.insert(Pet.create(4));
    Sql sql = Sqls.create("SELECT * FROM t_pet $condition");
    sql.setCondition(Cnd.where("name", "like", "pet_%").asc("name"));
    sql.setCallback(new SqlCallback() {
      public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
        List<Pet> pets = new ArrayList<Pet>(4);
        while (rs.next())
          pets.add(dao.getObject(Pet.class, rs, null));
        return pets;
View Full Code Here


        // 这个仅仅测试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;
                    boolean ts4 = false;
View Full Code Here

    public void test_query_without_entity() {
        pojos.initPet();
        dao.insert(Pet.create(4));
        Sql sql = Sqls.create("SELECT * FROM t_pet $condition");
        sql.setCondition(Cnd.where("name", "like", "pet_%").asc("name"));
        sql.setCallback(new SqlCallback() {
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                List<Pet> pets = new ArrayList<Pet>(4);
                while (rs.next())
                    pets.add(dao.getObject(Pet.class, rs, null));
                return pets;
View Full Code Here

        // 这个仅仅测试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;
                    boolean ts4 = false;
View Full Code Here

    public <T> T queryForObject(String sql,
                                Map<String, Object> vars,
                                Map<String, Object> params,
                                Class<T> classOfT) {
        Sql sqlObj = createSqlObj(sql, params);
        sqlObj.setCallback(new SqlCallback() {
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                if (null != rs && rs.next())
                    return rs.getObject(1);
                return null;
            }
View Full Code Here

                                    Map<String, Object> vars,
                                    Map<String, Object> params,
                                    final Class<T> classOfT) {
        Sql sqlObj = createSqlObj(sql, params);

        sqlObj.setCallback(new SqlCallback() {
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                List<T> list = new ArrayList<T>();
                while (rs.next()) {
                    T result = Castors.me().castTo(rs.getObject(1), classOfT);
                    list.add(result);
View Full Code Here

TOP

Related Classes of org.nutz.dao.sql.SqlCallback

Copyright © 2018 www.massapicom. 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.