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

com.jpattern.orm.session.reader.IntegerResultSetReader Maven / Gradle / Ivy

There is a newer version: 6.3.0
Show newest version
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 IntegerResultSetReader implements ResultSetReader {

	@Override
	public Integer read(final ResultSet resultSet) throws SQLException {
		if ( resultSet.next() ) {
			int result = resultSet.getInt(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