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

com.jpattern.orm.session.reader.LongResultSetReader 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 LongResultSetReader implements ResultSetReader {

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