You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While profiling the app I've noticed performance bottlenecks with default argument binder.
Is there a way in JDBI to use List of custom objects, custom argument factory and @SqlBatch?
The issue is that POJO is not passed into the Argument Factory - individual fields are passed in. I would expect one invocation of prepare method per pojo from the list, not the invocation for each of the fields.
public interface AbcDao {
@SqlBatch("insert into table_abc_entry(property1, property2) values(:property1, property2)")
@RegisterArgumentFactory(AbcEntryArgumentFactory.class)
void store(List<AbcEntry> entries);
}
class AbcEntryArgumentFactory implements ArgumentFactory.Preparable {
@Override
public Optional<Function<Object, Argument>> prepare(Type type, ConfigRegistry config) {
log.info(type);
if (AbcEntry.class.equals(type)) {
return Optional.of(
value -> (p, s, c) -> {
var abcEntry = (AbcEntry) value;
s.setString(p, abcEntry.getProperty1());
s.setString(p + 1, abcEntry.getProperty1());
}
);
}
return Optional.empty();
}
}
class AbcEntry {
String property1;
String property2;
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
While profiling the app I've noticed performance bottlenecks with default argument binder.
Is there a way in JDBI to use List of custom objects, custom argument factory and @SqlBatch?
The issue is that POJO is not passed into the Argument Factory - individual fields are passed in. I would expect one invocation of prepare method per pojo from the list, not the invocation for each of the fields.
Beta Was this translation helpful? Give feedback.
All reactions