Class EntityReader
- java.lang.Object
-
- javax.batch.api.chunk.AbstractItemReader
-
- org.hibernate.search.batch.jsr352.core.massindexing.step.spi.EntityReader
-
- All Implemented Interfaces:
ItemReader
@Named("org.hibernate.search.jsr352.massindexing.impl.steps.lucene.EntityReader") @HibernateSearchPartitionScoped public class EntityReader extends AbstractItemReader
Entity reader reads entities from database. During the open of the read stream, this reader builds a scrollable result. Then, it scrolls from one entity to another at each reading. An entity reader reaches its end when there’s no more item to read. Each reader contains only one entity type.The reading range is restricted by the
PartitionBound
, which always represents as a left-closed interval. SeeHibernateSearchPartitionMapper
for more information about these bounds.- Author:
- Mincong Huang
-
-
Constructor Summary
Constructors Constructor Description EntityReader()
EntityReader(String serializedCacheMode, String entityName, String serializedEntityFetchSize, String serializedCheckpointInterval, String serializedSessionClearInterval, String hql, String serializedMaxResultsPerEntity, String partitionIdStr, String serializedLowerBound, String serializedUpperBound, String indexScopeName, JobContext jobContext, StepContext stepContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Serializable
checkpointInfo()
The checkpointInfo method returns the current checkpoint data for this reader.void
close()
Close operation(s) before the class destruction.void
open(Serializable checkpointInfo)
Initialize the environment.Object
readItem()
Read item from database using JPA.
-
-
-
Constructor Detail
-
EntityReader
public EntityReader()
-
EntityReader
public EntityReader(String serializedCacheMode, String entityName, String serializedEntityFetchSize, String serializedCheckpointInterval, String serializedSessionClearInterval, String hql, String serializedMaxResultsPerEntity, String partitionIdStr, String serializedLowerBound, String serializedUpperBound, String indexScopeName, JobContext jobContext, StepContext stepContext)
-
-
Method Detail
-
open
public void open(Serializable checkpointInfo) throws IOException, ClassNotFoundException
Initialize the environment. If checkpoint does not exist, then it should be the first open. If checkpoint exists, then it isn't the first open, re-use the input object "checkpoint" as the last ID already read.- Specified by:
open
in interfaceItemReader
- Overrides:
open
in classAbstractItemReader
- Parameters:
checkpointInfo
- The last checkpoint info persisted in the batch runtime, previously given by checkpointInfo(). If this is the first start, then the checkpoint will be null.- Throws:
IOException
ClassNotFoundException
-
close
public void close()
Close operation(s) before the class destruction.- Specified by:
close
in interfaceItemReader
- Overrides:
close
in classAbstractItemReader
-
readItem
public Object readItem()
Read item from database using JPA. Each read, there will be only one entity fetched.- Specified by:
readItem
in interfaceItemReader
- Specified by:
readItem
in classAbstractItemReader
-
checkpointInfo
public Serializable checkpointInfo()
The checkpointInfo method returns the current checkpoint data for this reader. It is called before a chunk checkpoint is committed.- Specified by:
checkpointInfo
in interfaceItemReader
- Overrides:
checkpointInfo
in classAbstractItemReader
- Returns:
- the checkpoint info
-
-