<commit_before>package org.simpleflatmapper.jdbc;


import org.simpleflatmapper.map.mapper.AbstractColumnNameDiscriminatorMapperFactory;
import org.simpleflatmapper.reflect.Getter;

import java.sql.ResultSet;

public final class NameBasedResultSetGetterFactory implements AbstractColumnNameDiscriminatorMapperFactory.ColumnNameGetterFactory<ResultSet> {
	public static final NameBasedResultSetGetterFactory INSTANCE = new NameBasedResultSetGetterFactory();

	private NameBasedResultSetGetterFactory() {
	}

	@SuppressWarnings("unchecked")
	@Override
	public <T> Getter<? super ResultSet, ? extends T> getGetter(final String discriminatorColumn, final Class<T> discriminatorType) {
		return new Getter<ResultSet, T>() {
			@Override
			public T get(ResultSet target) throws Exception {
				return target.getObject(discriminatorColumn, discriminatorType);
			}
		};
	}
}<commit_msg>better error reporting when resultset does not support getObject(String, Class)<commit_after>package org.simpleflatmapper.jdbc;


import org.simpleflatmapper.map.mapper.AbstractColumnNameDiscriminatorMapperFactory;
import org.simpleflatmapper.reflect.Getter;

import java.sql.ResultSet;

public final class NameBasedResultSetGetterFactory implements AbstractColumnNameDiscriminatorMapperFactory.ColumnNameGetterFactory<ResultSet> {
	public static final NameBasedResultSetGetterFactory INSTANCE = new NameBasedResultSetGetterFactory();

	private NameBasedResultSetGetterFactory() {
	}

	@SuppressWarnings("unchecked")
	@Override
	public <T> Getter<? super ResultSet, ? extends T> getGetter(final String discriminatorColumn, final Class<T> discriminatorType) {
		return new Getter<ResultSet, T>() {
			@Override
			public T get(ResultSet target) throws Exception {
				try {
					return target.getObject(discriminatorColumn, discriminatorType);
				} catch (NoSuchMethodError e) {
					throw jdbc40Error(target, e);	
				} catch (UnsupportedOperationException e) {
					throw jdbc40Error(target, e);
				}
			}

			private Exception jdbc40Error(ResultSet target, Throwable e) {
				String message = "The ResultSet " + target.getClass().getName() + " does not support the T getObject(String, Class<T>) method, " +
						"you will need to use the JdbcMapperFactory.discriminator(Class<T> commonType, final String discriminatorColumn, CheckedBiFunction<S, String, V> discriminatorFieldAccessor, Consumer<DiscriminatorConditionBuilder<S, V, T>> consumer) call passing ResultSet::getXXX as the discriminatorFieldAccessor reason : " + e.getMessage();
				return new UnsupportedOperationException(message, e);
			}
		};
	}
}
{'fraction_non_alphanumeric': 0.08323699421965318, 'fraction_numerical': 0.0023121387283236996, 'mean_word_length': 6.292134831460674, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2281172', 'n_tokens_mistral': 778, 'n_tokens_neox': 723, 'n_words': 176}