Package org.springframework.batch.core
Class Entity
- java.lang.Object
- org.springframework.batch.core.Entity
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
JobExecution
,JobInstance
,StepExecution
public class Entity extends java.lang.Object implements java.io.Serializable
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:
- Serialized Form
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object other)
Attempt to establish identity based on id if both exist.java.lang.Long
getId()
java.lang.Integer
getVersion()
int
hashCode()
Use ID if it exists to establish hash code, otherwise fall back to Object.hashCode().void
incrementVersion()
Increment the version numbervoid
setId(java.lang.Long id)
void
setVersion(java.lang.Integer version)
Public setter for the version needed only by repository methods.java.lang.String
toString()
Method Detail
getId
public java.lang.Long getId()
setId
public void setId(java.lang.Long id)
getVersion
public java.lang.Integer getVersion()
- Returns:
- the version
setVersion
public void setVersion(java.lang.Integer version)
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
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
equals
public boolean equals(java.lang.Object other)
Attempt to establish identity based on id if both exist. If either id does not exist use Object.equals().- Overrides:
equals
in classjava.lang.Object
- See Also:
Object.equals(java.lang.Object)
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.- Overrides:
hashCode
in classjava.lang.Object
- See Also:
Object.hashCode()