Class AbstractEntity

java.lang.Object
org.fryske_akademy.jpa.AbstractEntity
All Implemented Interfaces:
Serializable, EntityInterface

@MappedSuperclass public class AbstractEntity extends Object implements EntityInterface
superclass for entities, defines auto generated id (GenerationType.IDENTITY), a version column and a function to check if the entity is transient (not in db yet). Jpa annotations are on getters which allows you to override. If you want to annotate fields in your subclasses be sure to annotate with AccessType.FIELD.
Author:
eduard
See Also:
  • Constructor Details

    • AbstractEntity

      public AbstractEntity()
  • Method Details

    • getId

      public Integer getId()
      Description copied from interface: EntityInterface
      an entity should have an id
      Specified by:
      getId in interface EntityInterface
      Returns:
    • setId

      public void setId(Integer id)
    • getVersion

      public int getVersion()
    • setVersion

      public void setVersion(int version)
    • hashCode

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

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

      public boolean isTransient()
      is the entity in the db?
      Specified by:
      isTransient in interface EntityInterface
      Returns:
      true when version < 0 (version default value is -1) or id is null