Class AbstractPersistable<PK extends Serializable>

java.lang.Object
org.springframework.data.jpa.domain.AbstractPersistable<PK>
Type Parameters:
PK - the type of the identifier.
All Implemented Interfaces:
org.springframework.data.domain.Persistable<PK>
Direct Known Subclasses:
AbstractAuditable

@MappedSuperclass public abstract class AbstractPersistable<PK extends Serializable> extends Object implements org.springframework.data.domain.Persistable<PK>
Abstract base class for entities. Allows parameterization of id type, chooses auto-generation and implements equals(Object) and hashCode() based on that id.
Author:
Oliver Gierke, Thomas Darimont, Mark Paluch, Greg Turnquist
  • Constructor Details

    • AbstractPersistable

      public AbstractPersistable()
  • Method Details

    • getId

      @Nullable public PK getId()
      Specified by:
      getId in interface org.springframework.data.domain.Persistable<PK extends Serializable>
    • setId

      protected void setId(@Nullable PK id)
      Sets the id of the entity.
      Parameters:
      id - the id to set
    • isNew

      public boolean isNew()
      Must be Transient in order to ensure that no JPA provider complains because of a missing setter.
      Specified by:
      isNew in interface org.springframework.data.domain.Persistable<PK extends Serializable>
      See Also:
      • Persistable.isNew()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object