org.simpleflatmapper.jdbc.impl.setter.PreparedStatementIndexSetterOnGetter Maven / Gradle / Ivy
package org.simpleflatmapper.jdbc.impl.setter;
import org.simpleflatmapper.converter.Context;
import org.simpleflatmapper.reflect.Getter;
import org.simpleflatmapper.util.ErrorHelper;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class PreparedStatementIndexSetterOnGetter implements PreparedStatementIndexSetter {
private final Getter
getter;
private final PreparedStatementIndexSetter setter;
public PreparedStatementIndexSetterOnGetter(PreparedStatementIndexSetter setter , Getter
getter) {
this.setter = setter;
this.getter = getter;
}
@Override
public void set(PreparedStatement ps, P value, int columnIndex, Context context) throws SQLException {
try {
setter.set(ps, getter.get(value), columnIndex, context);
} catch (Exception e) {
ErrorHelper.rethrow(e);
}
}
}