public abstract class AbstractNeo4jItemReader<T> extends AbstractPaginatedDataItemReader<T> implements org.springframework.beans.factory.InitializingBean
Restartable ItemReader
that reads objects from the graph database Neo4j
via a paging technique.
It executes cypher queries built from the statement fragments provided to
retrieve the requested data. The query is executed using paged requests of
a size specified in AbstractPaginatedDataItemReader.setPageSize(int)
. Additional pages are requested
as needed when the AbstractItemCountingItemStreamItemReader.read()
method is called. On restart, the reader
will begin again at the same number item it left off at.
Performance is dependent on your Neo4J configuration (embedded or remote) as well as page size. Setting a fairly large page size and using a commit interval that matches the page size should provide better performance.
This implementation is thread-safe between calls to
AbstractItemCountingItemStreamItemReader.open(org.springframework.batch.item.ExecutionContext)
, however you
should set saveState=false
if used in a multi-threaded
environment (no restart available).
Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.logging.Log |
logger |
page, pageSize, results
Constructor and Description |
---|
AbstractNeo4jItemReader() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Checks mandatory properties
|
protected java.lang.String |
generateLimitCypherQuery() |
protected java.util.Map<java.lang.String,java.lang.Object> |
getParameterValues() |
protected org.neo4j.ogm.session.SessionFactory |
getSessionFactory() |
protected java.lang.Class<T> |
getTargetType() |
void |
setMatchStatement(java.lang.String matchStatement)
An optional match fragment of the cypher query.
|
void |
setOrderByStatement(java.lang.String orderByStatement)
A list of properties to order the results by.
|
void |
setParameterValues(java.util.Map<java.lang.String,java.lang.Object> parameterValues)
Optional parameters to be used in the cypher query.
|
void |
setReturnStatement(java.lang.String returnStatement)
The return statement of the cypher query.
|
void |
setSessionFactory(org.neo4j.ogm.session.SessionFactory sessionFactory)
Establish the session factory for the reader.
|
void |
setStartStatement(java.lang.String startStatement)
The start segment of the cypher query.
|
void |
setTargetType(java.lang.Class<T> targetType)
The object type to be returned from each call to
AbstractItemCountingItemStreamItemReader.read() |
void |
setWhereStatement(java.lang.String whereStatement)
An optional where fragment of the cypher query.
|
doClose, doOpen, doPageRead, doRead, jumpToItem, setPageSize
close, getCurrentItemCount, isSaveState, open, read, setCurrentItemCount, setMaxItemCount, setSaveState, update
getExecutionContextKey, setExecutionContextName, setName
public void setParameterValues(java.util.Map<java.lang.String,java.lang.Object> parameterValues)
parameterValues
- the parameter values to be used in the cypher queryprotected final java.util.Map<java.lang.String,java.lang.Object> getParameterValues()
public void setStartStatement(java.lang.String startStatement)
startStatement
- the start fragment of the cypher query.public void setReturnStatement(java.lang.String returnStatement)
returnStatement
- the return fragment of the cypher query.public void setMatchStatement(java.lang.String matchStatement)
matchStatement
- the match fragment of the cypher querypublic void setWhereStatement(java.lang.String whereStatement)
whereStatement
- where fragment of the cypher querypublic void setOrderByStatement(java.lang.String orderByStatement)
orderByStatement
- order by fragment of the cypher query.protected org.neo4j.ogm.session.SessionFactory getSessionFactory()
public void setSessionFactory(org.neo4j.ogm.session.SessionFactory sessionFactory)
sessionFactory
- the factory to use for the reader.public void setTargetType(java.lang.Class<T> targetType)
AbstractItemCountingItemStreamItemReader.read()
targetType
- the type of object to return.protected final java.lang.Class<T> getTargetType()
protected java.lang.String generateLimitCypherQuery()
public void afterPropertiesSet() throws java.lang.Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
java.lang.Exception
InitializingBean.afterPropertiesSet()