Class AbstractJpaEntity<T extends IdentifiableEntity,​U extends EntityIdentifier>

  • Type Parameters:
    T - the class name of the represented entity.
    U - the unique identifier class used by the entity to identify it uniquely in the persistence context.
    All Implemented Interfaces:
    Serializable, IdentifiableEntity
    Direct Known Subclasses:
    BasicJpaEntity, SilverpeasJpaEntity

    @MappedSuperclass
    public abstract class AbstractJpaEntity<T extends IdentifiableEntity,​U extends EntityIdentifier>
    extends Object
    implements IdentifiableEntity
    Abstract implementation of the IdentifiableEntity interface that uses the JPA API. This implementation defines all the common methods that can be required by the more concrete entities and that puts in place the JPA mechanical required for their persistence according to the basic JPA related rules in the Silverpeas Persistence API such as the unique identifier management. Please be careful with the child entity classes about the use of @PrePersist and @PreUpdate annotations. In most of cases you don't need to use them, but to override performBeforePersist() or performBeforeUpdate() methods.
    Author:
    mmoquillon
    See Also:
    Serialized Form
    • Constructor Detail

      • AbstractJpaEntity

        public AbstractJpaEntity()
    • Method Detail

      • getId

        public String getId()
        Description copied from interface: IdentifiableEntity
        Gets the unique identifier of this entity.
        Specified by:
        getId in interface IdentifiableEntity
        Returns:
        the entity unique identifier in the form of a string.
      • isPersisted

        public boolean isPersisted()
        Description copied from interface: IdentifiableEntity
        Indicates if the entity is persisted.
        Specified by:
        isPersisted in interface IdentifiableEntity
        Returns:
        true if the entity is stored in a data source, false otherwise.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getNativeId

        protected U getNativeId()
        Gets the native representation of the entity identifier.
        Returns:
        the native representation of the unique identifier of this entity.
      • setId

        protected T setId​(String id)
        Sets the specified unique identifier to this entity.
        Parameters:
        id - the new unique identifier of the entity.
        Returns:
        itself.
      • performBeforePersist

        protected abstract void performBeforePersist()
        Performs some treatments before this entity is persisted into a repository.
      • performBeforeUpdate

        protected abstract void performBeforeUpdate()
        Performs some treatments before its counterpart in a repository is updated with the changes in this entity.
      • performBeforeRemove

        protected abstract void performBeforeRemove()
        Performs some treatments before this entity is removed from a repository.