-
Notifications
You must be signed in to change notification settings - Fork 75
Errors_CTFM_SETTER_NOT_FOUND
Arnaud Roger edited this page Feb 21, 2016
·
3 revisions
When mapping from an object to a target - ie. PreparedStatement - sfm could not find a setter on the target that can take the type of the property.
You will need to provide a custom setter to the framework that will build the specific type from the source object. you can also provide a setter factory that will build a getter based on the field key.
JdbcMapperFactory
.newInstance()
.addColumnProperty("bar", new SetterProperty(new Setter<PreparedStatement, Bar2Prop>() {
@Override
public void set(PreparedStatement target, Bar2Prop value) throws Exception {
target.setString(3, value.getVal());
target.setInt(4, value.getI());
}
}))
.buildFrom(Foo2.class)
.addColumn("bar")
.mapper();
CsvWriter
.from(Foo2.class)
.column("bar", new SetterProperty(new Setter<Appendable, Bar2Prop>() {
@Override
public void set(Appendable target, Bar2Prop value) throws Exception {
target.append(value.getVal()).append(":").append(String.valueOf(value.getI()));
}
}))
.to(sb)
.append(new Foo2(new Bar2Prop("val", 3)));