Package com.jk.data.dataaccess.orm
Class JKEntity
java.lang.Object
com.jk.data.dataaccess.orm.JKEntity
- All Implemented Interfaces:
Serializable
This class provides common functionality and annotations for entity classes.
Entities that extend this class are expected to include annotations such as `@Id`, `@GeneratedValue`, and `@Column` for mapping to database tables.
This class offers utility methods for working with entities, such as retrieving table name, column information, and sorting information.
- Version:
- 1.0
- Author:
- Dr. Jalal H. Kiswani
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Indicates whether some other object is "equal to" this one.This method retrieves the alias name for this entity class.static List<JKColumnWrapper>
getColumns
(Class<? extends JKEntity> clas) This method retrieves a list of column wrappers for the columns in the specified entity class.jakarta.persistence.Column
This method retrieves the first column in this entity class that is not marked as the primary key.This method gets the column wrapper representing the primary key (ID column) for thisJKEntity
class.static JKColumnWrapper
getIdColumn
(Class<? extends JKEntity> clas) This method gets the column wrapper representing the primary key (ID column) for the specified JKEntity class.<T> T
This method gets the value of the primary key (ID) field for this entity.static JKSortInfo
getSortInfo
(Class<? extends JKEntity> clas) This method retrieves the sort information associated with a class.This method gets the primary table name of this entity.int
hashCode()
Returns a hash code value for the object.static void
printFieldAnnotations
(Field field) This method prints the annotations applied to a given field.void
This method prints the annotations of fields within the currentJKEntity
class.toString()
Returns a string representation of the object.
-
Constructor Details
-
JKEntity
public JKEntity()This method constructs a newJKEntity
.
-
-
Method Details
-
getTableName
This method gets the primary table name of this entity.- Returns:
- the primary table name of this entity.
-
getIdValue
public <T> T getIdValue()This method gets the value of the primary key (ID) field for this entity.- Type Parameters:
T
- Specifies the type of the primary key value.- Returns:
- the value of the primary key field.
-
getFirstNonIdColumn
public jakarta.persistence.Column getFirstNonIdColumn()This method retrieves the first column in this entity class that is not marked as the primary key.- Returns:
- the first non-primary key column in the entity class, or null if none was found.
-
getColumns
This method retrieves a list of column wrappers for the columns in the specified entity class.- Parameters:
clas
- Specifies the entity class for which to retrieve the columns.- Returns:
- a list of column wrappers representing the columns in the entity class.
-
getIdColumn
This method gets the column wrapper representing the primary key (ID column) for thisJKEntity
class.- Returns:
- a
JKColumnWrapper
representing the primary key column.
-
getIdColumn
This method gets the column wrapper representing the primary key (ID column) for the specified JKEntity class.- Parameters:
clas
- Specifies theJKEntity
class for which to retrieve the ID column.- Returns:
- a
JKColumnWrapper
representing the primary key column.
-
printFieldsAnnotations
public void printFieldsAnnotations()This method prints the annotations of fields within the currentJKEntity
class. -
printFieldAnnotations
This method prints the annotations applied to a given field.- Parameters:
field
- Specifies the field for which annotations should be printed.
-
toString
Returns a string representation of the object. -
getSortInfo
This method retrieves the sort information associated with a class.- Parameters:
clas
- Specifies the class for which sort information is retrieved.- Returns:
- the sort information associated with the class, or null if none is found.
-
equals
Indicates whether some other object is "equal to" this one.The
equals
method implements an equivalence relation on non-null object references:- It is reflexive: for any non-null reference value
x
,x.equals(x)
should returntrue
. - It is symmetric: for any non-null reference values
x
andy
,x.equals(y)
should returntrue
if and only ify.equals(x)
returnstrue
. - It is transitive: for any non-null reference values
x
,y
, andz
, ifx.equals(y)
returnstrue
andy.equals(z)
returnstrue
, thenx.equals(z)
should returntrue
. - It is consistent: for any non-null reference values
x
andy
, multiple invocations ofx.equals(y)
consistently returntrue
or consistently returnfalse
, provided no information used inequals
comparisons on the objects is modified. - For any non-null reference value
x
,x.equals(null)
should returnfalse
.
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
- It is reflexive: for any non-null reference value
-
hashCode
public int hashCode()Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided byHashMap
.The general contract of
hashCode
is:- Whenever it is invoked on the same object more than once during
an execution of a Java application, the
hashCode
method must consistently return the same integer, provided no information used inequals
comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application. - If two objects are equal according to the
equals
method, then calling thehashCode
method on each of the two objects must produce the same integer result. - It is not required that if two objects are unequal
according to the
equals
method, then calling thehashCode
method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
- Whenever it is invoked on the same object more than once during
an execution of a Java application, the
-
getAliasName
This method retrieves the alias name for this entity class.- Returns:
- the alias name, which is the simple name of the class.
-