Skip to content

Instantly share code, notes, and snippets.

@theflofly
Created February 11, 2016 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theflofly/1f36afc642d92a4e94d3 to your computer and use it in GitHub Desktop.
Save theflofly/1f36afc642d92a4e94d3 to your computer and use it in GitHub Desktop.
package com.tcb.issue1.job;
import com.tcb.issue1.model.Offer;
import com.tcb.issue1.repository.OfferRepository;
import org.springframework.batch.item.ItemWriter;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
/**
* This class is the writer for the Offer object, it writes a list of Offers into the Elasticsearch database.
*
* Created by Florian.Courtial on 28/01/16.
*/
public class OfferItemWriter implements ItemWriter<Offer>, InitializingBean {
@Autowired
private OfferRepository offerRepository;
@Override
public void afterPropertiesSet() throws Exception {}
@Override
public void write(List<? extends Offer> list) throws Exception {
offerRepository.save(list);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment