All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sf.database.jdbc.rowmapper.SetRowMapper Maven / Gradle / Ivy

The newest version!
package sf.database.jdbc.rowmapper;

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.LinkedHashSet;
import java.util.Set;


/**
 * 结果集转为set
 */
public class SetRowMapper implements RowMapper> {

    @Override
    public Set handle(ResultSet rs, ResultSetMetaData rsmd, int rowNum) throws SQLException {
        int cols = rsmd.getColumnCount();
        Set result = new LinkedHashSet<>();
        for (int i = 0; i < cols; i++) {
            result.add(rs.getObject(i + 1));
        }
        return result;
    }

}