com.jpattern.orm.session.reader.BooleanResultSetReader Maven / Gradle / Ivy
package com.jpattern.orm.session.reader;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.jpattern.orm.exception.OrmNotUniqueResultException;
import com.jpattern.orm.session.ResultSetReader;
/**
*
* @author ufo
*
*/
public class BooleanResultSetReader implements ResultSetReader {
@Override
public Boolean read(final ResultSet resultSet) throws SQLException {
if ( resultSet.next() ) {
Boolean result = resultSet.getBoolean(1);
if (resultSet.next()) {
throw new OrmNotUniqueResultException("The query execution returned a number of rows higher than 1");
}
return result;
}
throw new OrmNotUniqueResultException("The query execution has returned zero rows. One row was expected");
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy