Class JKBaseEntity

java.lang.Object
com.jk.core.jpa.JKBaseEntity
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
Account, Email, Event

@MappedSuperclass public class JKBaseEntity extends Object implements Serializable
This class provides common properties for database base entities.
Version:
1.0
Author:
Dr. Jalal H. Kiswani
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <T extends JKBaseEntity>
    boolean
    equals(Class<T> clas, T t)
    This method checks equality by comparing fields that have the same type as the provided class.
    void
    This method is invoked after the entity is loaded from the database.
    void
    This method is invoked before the entity is persisted (inserted) into the database.
    void
    This method is invoked before the entity is updated in the database.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JKBaseEntity

      public JKBaseEntity()
  • Method Details

    • prePersist

      public void prePersist()
      This method is invoked before the entity is persisted (inserted) into the database.

      This method initializes the creation and modification dates with the current date and time.

    • preUpdate

      public void preUpdate()
      This method is invoked before the entity is updated in the database.

      This method updates the modification date with the current date and time.

    • postUpdate

      public void postUpdate()
      This method is invoked after the entity is loaded from the database.

      This method ensures backward compatibility by initializing dates if they are null.

    • equals

      public <T extends JKBaseEntity> boolean equals(Class<T> clas, T t)
      This method checks equality by comparing fields that have the same type as the provided class.
      Type Parameters:
      T - Specifies the type of the entity class extending JKBaseEntity.
      Parameters:
      clas - Specifies the class of the entity to compare.
      t - Specifies the instance of the entity to compare.
      Returns:
      true if the instances are equal, false otherwise.