com.jpattern.orm.session.reader.BigDecimalResultSetReader Maven / Gradle / Ivy
package com.jpattern.orm.session.reader;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.jpattern.orm.exception.OrmNotUniqueResultException;
import com.jpattern.orm.session.ResultSetReader;
/**
*
* @author ufo
*
*/
public class BigDecimalResultSetReader implements ResultSetReader {
@Override
public BigDecimal read(final ResultSet resultSet) throws SQLException {
if ( resultSet.next() ) {
BigDecimal result = resultSet.getBigDecimal(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