Package com.jk.core.jpa
Class JKBaseEntity
java.lang.Object
com.jk.core.jpa.JKBaseEntity
- All Implemented Interfaces:
Serializable
This class provides common properties for database base entities.
- Version:
- 1.0
- Author:
- Dr. Jalal H. Kiswani
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T extends JKBaseEntity>
booleanThis 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.
-
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
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 extendingJKBaseEntity
.- 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.
-