Package org.springframework.batch.core
Class Entity
java.lang.Object
org.springframework.batch.core.Entity
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
JobExecution
,JobInstance
,StepExecution
Batch Domain Entity class. Any class that should be uniquely identifiable from another
should subclass from Entity. See Domain Driven Design, by Eric Evans, for more
information on this pattern and the difference between Entities and Value Objects.
- Author:
- Lucas Ward, Dave Syer
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Attempt to establish identity based onid
if both exist.getId()
int
hashCode()
Useid
, if it exists, to establish a hash code.void
Increment the version number.void
void
setVersion
(Integer version) Public setter for the version.toString()
Creates a string representation of theEntity
, including theid
,version
, and class name.
-
Constructor Details
-
Method Details
-
getId
- Returns:
- The ID associated with the
Entity
.
-
setId
- Parameters:
id
- The ID for theEntity
.
-
getVersion
- Returns:
- the version.
-
setVersion
Public setter for the version. Needed only by repository methods.- Parameters:
version
- The version to set.
-
incrementVersion
public void incrementVersion()Increment the version number. -
toString
Creates a string representation of theEntity
, including theid
,version
, and class name. -
equals
Attempt to establish identity based onid
if both exist. If eitherid
does not exist, useObject.equals()
. -
hashCode
public int hashCode()Useid
, if it exists, to establish a hash code. Otherwise fall back toObject.hashCode()
. It is based on the same information asequals
, so, if that changes, this will. Note that this follows the contract ofObject.hashCode()
but will cause problems for anyone adding an unsavedEntity
to aSet
becauseSet.contains()
almost certainly returns false for theEntity
after it is saved. Spring Batch does not store any of its entities in sets as a matter of course, so this is internally consistent. Clients should not be exposed to unsaved entities.
-