com.jpattern.orm.session.reader.StringResultSetReader 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 StringResultSetReader implements ResultSetReader {
@Override
public String read(final ResultSet resultSet) throws SQLException {
if ( resultSet.next() ) {
String result = resultSet.getString(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 - 2025 Weber Informatics LLC | Privacy Policy