Example usage for org.apache.commons.dbutils.handlers BeanListHandler BeanListHandler

List of usage examples for org.apache.commons.dbutils.handlers BeanListHandler BeanListHandler

Introduction

In this page you can find the example usage for org.apache.commons.dbutils.handlers BeanListHandler BeanListHandler.

Prototype

public BeanListHandler(Class<T> type) 

Source Link

Document

Creates a new instance of BeanListHandler.

Usage

From source file:org.gaixie.jibu.security.dao.impl.RoleDAOOracle.java

/**
 * {@inheritDoc}//from  w  ww .  j a  v a 2  s  .co m
 * <p>
 * user.getId() ? null
 */
public List<Role> find(Connection conn, User user) throws SQLException {
    ResultSetHandler<List<Role>> h = new BeanListHandler(Role.class);
    return run.query(conn,
            "SELECT node.id, node.name, node.description, node.lft, node.rgt "
                    + " FROM roles node, user_role_map urm " + " WHERE node.id = urm.role_id "
                    + " AND urm.user_id = ? ",
            h, user.getId());
}

From source file:org.gaixie.jibu.security.dao.impl.SettingDAODerby.java

public List<Setting> findByName(Connection conn, String name) throws SQLException {
    ResultSetHandler<List<Setting>> h = new BeanListHandler(Setting.class);
    return run.query(conn,
            "SELECT id,name,value,sortindex,enabled FROM settings WHERE name =? ORDER BY sortindex", h, name);
}

From source file:org.gaixie.jibu.security.dao.impl.SettingDAODerby.java

public List<Setting> getAllDefault(Connection conn) throws SQLException {
    ResultSetHandler<List<Setting>> h = new BeanListHandler(Setting.class);
    return run.query(conn, "SELECT id,name,value,sortindex,enabled FROM settings WHERE sortindex =0", h);
}

From source file:org.gaixie.jibu.security.dao.impl.SettingDAODerby.java

public List<Setting> findByUsername(Connection conn, String username) throws SQLException {
    ResultSetHandler<List<Setting>> h = new BeanListHandler(Setting.class);
    String sql = " SELECT s.id,s.name,s.value,s.sortindex,s.enabled \n"
            + " FROM settings s, userbase u, user_setting_map usm \n" + " WHERE u.username=? \n"
            + "       AND u.id = usm.user_id \n" + "       AND usm.setting_id = s.id \n";

    return run.query(conn, sql, h, username);
}

From source file:org.gaixie.jibu.security.dao.impl.UserDAODerby.java

/**
 * {@inheritDoc}/*from w  w  w.j a v  a2  s.  co m*/
 * <p>
 *  List  User  password  null
 */
public List<User> find(Connection conn, User user) throws SQLException {
    ResultSetHandler<List<User>> h = new BeanListHandler(User.class);
    String sql = "SELECT id,username,fullname,emailaddress,enabled FROM userbase \n";
    try {
        String s = SQLBuilder.beanToSQLClause(user, "AND");
        sql = sql + SQLBuilder.getWhereClause(s);
    } catch (JibuException e) {
        throw new SQLException(e.getMessage());
    }
    return run.query(conn, sql, h);
}

From source file:org.gaixie.jibu.security.dao.impl.UserDAODerby.java

/**
 * {@inheritDoc}//from w w  w .j av  a  2 s.  c o m
 * <p>
 *  List  User  password  null
 */
public List<User> find(Connection conn, User user, Criteria criteria) throws SQLException {
    ResultSetHandler<List<User>> h = new BeanListHandler(User.class);
    String sql = "SELECT id,username,fullname,emailaddress,enabled FROM userbase \n";
    try {
        String s = SQLBuilder.beanToSQLClause(user, "AND");
        sql = sql + SQLBuilder.getWhereClause(s);
        sql = SQLBuilder.getSortClause(sql, criteria);
        sql = SQLBuilder.getPagingClause(sql, criteria);
    } catch (JibuException e) {
        throw new SQLException(e.getMessage());
    }
    return run.query(conn, sql, h);
}

From source file:org.gaixie.jibu.security.dao.impl.UserDAODerby.java

/**
 * {@inheritDoc}//from w ww  . j  a v a2  s . c  o m
 * <p>
 *  List  User  password  nullrole.getId() ? null
 */
public List<User> find(Connection conn, Role role) throws SQLException {
    ResultSetHandler<List<User>> h = new BeanListHandler(User.class);
    return run.query(conn,
            "SELECT u.id, u.username, u.fullname, u.emailaddress,u.enabled "
                    + " FROM roles AS r, user_role_map AS m, userbase AS u " + " WHERE u.id = m.user_id "
                    + " AND m.role_id = r.id " + " AND r.id = ? ",
            h, role.getId());
}

From source file:org.gaixie.jibu.security.dao.impl.UserDAODerby.java

/**
 * {@inheritDoc}/*from   www  . j  ava2  s  . c  om*/
 * <p>
 *  List  User  password  nullauth.getId() ? null
 */
public List<User> find(Connection conn, Authority auth) throws SQLException {
    ResultSetHandler<List<User>> h = new BeanListHandler(User.class);
    return run.query(conn, "SELECT u.id, u.username, u.fullname, u.emailaddress,u.enabled "
            + " FROM roles AS node, roles AS parent, user_role_map AS urm, role_authority_map AS ram, userbase AS u "
            + " WHERE parent.id = ram.role_id " + " AND node.lft BETWEEN parent.lft AND parent.rgt "
            + " AND node.id = urm.role_id " + " AND urm.user_id = u.id " + " AND ram.authority_id = ? ", h,
            auth.getId());
}

From source file:org.gaixie.jibu.security.dao.impl.UserDAOOracle.java

/**
 * {@inheritDoc}/*from   ww  w  .  j  a  v a 2  s .  com*/
 * <p>
 *  List  User  password  nullrole.getId() ? null
 */
public List<User> find(Connection conn, Role role) throws SQLException {
    ResultSetHandler<List<User>> h = new BeanListHandler(User.class);
    return run.query(conn,
            "SELECT u.id, u.username, u.fullname, u.emailaddress,u.enabled "
                    + " FROM roles r, user_role_map m, userbase u " + " WHERE u.id = m.user_id "
                    + " AND m.role_id = r.id " + " AND r.id = ? ",
            h, role.getId());
}

From source file:org.gaixie.jibu.security.dao.impl.UserDAOOracle.java

/**
 * {@inheritDoc}//from   ww  w  .  j a va 2 s .co  m
 * <p>
 *  List  User  password  nullauth.getId() ? null
 */
public List<User> find(Connection conn, Authority auth) throws SQLException {
    ResultSetHandler<List<User>> h = new BeanListHandler(User.class);
    return run.query(conn,
            "SELECT u.id, u.username, u.fullname, u.emailaddress,u.enabled "
                    + " FROM roles node, roles parent, user_role_map urm, role_authority_map ram, userbase u "
                    + " WHERE parent.id = ram.role_id " + " AND node.lft BETWEEN parent.lft AND parent.rgt "
                    + " AND node.id = urm.role_id " + " AND urm.user_id = u.id " + " AND ram.authority_id = ? ",
            h, auth.getId());
}