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
I want to make a subclass from MongoItemWriter to override doWrite() method but my subclass can't access MongoItemWriter.template.
If my subclass has MongoOperations template variable then afterPropertiesSet() method should be overridden to skip assertion logic.
Current sample subclass code
@Setter
public class CustomMongoItemWriter<T> extends MongoItemWriter<T> {
private MongoOperations template;
@Override
protected void doWrite(List<? extends T> items) {
for (Object object : items) {
Movie movie = (Movie) object
Query query = Query.query(Criteria.where("_id").is(movie.getId()));
Update update = new Update()
.set("tags", movie.getTags())
.set("update", LocalDateTime.now());
template.updateFirst(query, update, Movie.class);
}
}
@Override
public void afterPropertiesSet() throws Exception {
// nothing to do
// Assert.state(template != null, "A MongoOperations implementation is required.");
}
}
Expected sample subclass code
public class CustomMongoItemWriter<T> extends MongoItemWriter<T> {
@Override
protected void doWrite(List<? extends T> items) {
for (Object object : items) {
Movie movie = (Movie) object;
Query query = Query.query(Criteria.where("_id").is(movie.getId()));
Update update = new Update()
.set("tags", movie.getTags())
.set("update", LocalDateTime.now());
template.updateFirst(query, update, Movie.class);
}
}
}
Takaaki Iida opened BATCH-2567 and commented
I want to make a subclass from MongoItemWriter to override doWrite() method but my subclass can't access MongoItemWriter.template.
If my subclass has MongoOperations template variable then afterPropertiesSet() method should be overridden to skip assertion logic.
Current sample subclass code
Expected sample subclass code
Affects: 4.0.0
Referenced from: commits cae2cab
The text was updated successfully, but these errors were encountered: