org.springframework.batch.core
Class Entity

java.lang.Object
  extended by org.springframework.batch.core.Entity
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
JobExecution, JobInstance, StepExecution

public class Entity
extends Object
implements 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

Constructor Summary
Entity()
           
Entity(Long id)
           
 
Method Summary
 boolean equals(Object other)
          Attempt to establish identity based on id if both exist.
 Long getId()
           
 Integer getVersion()
           
 int hashCode()
          Use ID if it exists to establish hash code, otherwise fall back to Object.hashCode().
 void incrementVersion()
          Increment the version number
 void setId(Long id)
           
 void setVersion(Integer version)
          Public setter for the version needed only by repository methods.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Entity

public Entity()

Entity

public Entity(Long id)
Method Detail

getId

public Long getId()

setId

public void setId(Long id)

getVersion

public Integer getVersion()
Returns:
the version

setVersion

public void setVersion(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 String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object other)
Attempt to establish identity based on id if both exist. If either id does not exist use Object.equals().

Overrides:
equals in class 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 unsaved Entity to a Set because Set.contains() will almost certainly return false for the Entity 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 class Object
See Also:
Object.hashCode()


Copyright © 2009 SpringSource. All Rights Reserved.