class Neo4jItemWriter<T> implements ItemWriter<T>, InitializingBean {

	protected static final Log logger = LogFactory.getLog(Neo4jItemWriter.class);

	private boolean delete = false;

	private SessionFactory sessionFactory;

	/**
	 * Boolean flag indicating whether the writer should save or delete the item at write
	 * time.
	 * @param delete true if write should delete item, false if item should be saved.
	 * Default is false.
	 */
	public void setDelete(boolean delete) {
		this.delete = delete;
	}

	/**
	 * Establish the session factory that will be used to create {@link Session} instances
	 * for interacting with Neo4j.
	 * @param sessionFactory sessionFactory to be used.
	 */
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	/**
	 * Checks mandatory properties
	 *
	 * @see InitializingBean#afterPropertiesSet()
	 */
	@Override
	public void afterPropertiesSet() throws Exception {
		Assert.state(this.sessionFactory != null, "A SessionFactory is required");
	}

	/**
	 * Write all items to the data store.
	 *
	 * @see org.springframework.batch.item.ItemWriter#write(Chunk)
	 */
	@Override
	public void write(Chunk<? extends T> chunk) throws Exception {
		if (!chunk.isEmpty()) {
			doWrite(chunk);
		}
	}

	/**
	 * Performs the actual write using the template. This can be overridden by a subclass
	 * if necessary.
	 * @param items the list of items to be persisted.
	 */
	protected void doWrite(Chunk<? extends T> items) {
		if (delete) {
			delete(items);
		}
		else {
			save(items);
		}
	}

	private void delete(Chunk<? extends T> items) {
		Session session = this.sessionFactory.openSession();

		for (T item : items) {
			session.delete(item);
		}
	}

	private void save(Chunk<? extends T> items) {<FILL_FUNCTION_BODY>}

}

		Session session = this.sessionFactory.openSession();

		for (T item : items) {
			session.save(item);
		}
	
<no_super_class>