Class AbstractPersistable<P extends Serializable>

  • Type Parameters:
    P - the type of the identifier.
    All Implemented Interfaces:
    org.springframework.data.domain.Persistable<P>
    Direct Known Subclasses:
    LocalizedEntity

    @MappedSuperclass
    public abstract class AbstractPersistable<P extends Serializable>
    extends Object
    implements org.springframework.data.domain.Persistable<P>
    Abstract base class for entities. Allows parameterization of id type, chooses auto-generation and implements equals(Object) and hashCode() based on that id. Based on AbstractPersistable but with public setter for id, it's required on editor and serializer on client side.
    Author:
    Oliver Gierke, Thomas Darimont, Mark Paluch, Manfred Tremmel
    • Constructor Detail

      • AbstractPersistable

        public AbstractPersistable()
    • Method Detail

      • getId

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

        public void setId​(@Nullable
                          P 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<P extends Serializable>
        See Also:
        Persistable.isNew()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object