Class Entity

java.lang.Object
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. 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, Mahmoud Ben Hassine
See Also:
  • Constructor Details

    • Entity

      public Entity()
      Default constructor for Entity.

      The ID defaults to zero.

    • Entity

      public Entity(Long id)
      The constructor for the Entity where the ID is established.
      Parameters:
      id - The ID for the entity.
  • Method Details

    • getId

      public Long getId()
      Returns:
      The ID associated with the Entity.
    • setId

      public void setId(Long id)
      Parameters:
      id - The ID for the Entity.
    • 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()
      Creates a string representation of the Entity, including the id, version, and class name.
      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:
    • hashCode

      public int hashCode()
      Use id, if it exists, to establish a hash code. Otherwise fall back to Object.hashCode(). It is based on the same information as equals, so, if that changes, this will. Note that this follows the contract of Object.hashCode() but will cause problems for anyone adding an unsaved Entity to a Set because Set.contains() almost certainly returns 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 this is internally consistent. Clients should not be exposed to unsaved entities.
      Overrides:
      hashCode in class Object
      See Also: