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. More information on this pattern
and the difference between Entities and Value Objects can be found in Domain
Driven Design by Eric Evans.
- Author:
- Lucas Ward, Dave Syer
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Attempt to establish identity based on id if both exist.getId()
int
hashCode()
Use ID if it exists to establish hash code, otherwise fall back to Object.hashCode().void
Increment the version numbervoid
void
setVersion
(Integer version) Public setter for the version needed only by repository methods.toString()
-
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
-
equals
Attempt to establish identity based on id if both exist. If either id does not exist use Object.equals(). -
hashCode
public int hashCode()Use ID if it exists to establish hash code, otherwise fall back to Object.hashCode(). Based on the same information as equals, so if that changes, this will. N.B. this follows the contract of Object.hashCode(), but will cause problems for anyone adding an unsavedEntity
to a Set because Set.contains() will almost certainly return false for theEntity
after it is saved. Spring Batch does not store any of its entities in Sets as a matter of course, so internally this is consistent. Clients should not be exposed to unsaved entities.
-