Type Parameters:
E - the type of the entity or projection.
ID - the type of the primary key, or Void in case of a projection without a primary key.
Record Components:
tableName - the name of the table or view.
type - the type of the entity or projection.
primaryKeyType - the type of the primary key.
columns - an immutable list of columns in the entity or projection.
All Implemented Interfaces:
Model <E,ID>
Represents the model of an entity or projection.
Constructor Summary
Constructors
Creates an instance of a ModelImpl record class.
Method Summary
All Methods Instance Methods Concrete Methods
Returns the value of the
columns record component.
final boolean
Indicates whether some other object is "equal to" this one.
Extracts the value for the specified column from the given record.
Extracts the values from the given record and maps them to the columns of the entity or projection.
final int
Returns a hash code value for this object.
boolean
Returns {code true} if the specified primary key represents a default value, false otherwise.
Returns the name of the table or view.
Returns the qualified name of the table or view, including the schema and escape characters where necessary.
Returns the schema, or empty String if the schema is not specified.
Returns the value of the
tableName record component.
Returns a string representation of this record class.
Returns the value of the
type record component.
Constructor Details
ModelImpl
Creates an instance of a ModelImpl record class.
Parameters:
tableName - the value for the tableName record component
type - the value for the type record component
primaryKeyType - the value for the primaryKeyType record component
columns - the value for the columns record component
Method Details
schema
Returns the schema, or empty String if the schema is not specified.
Specified by:
schema in interface Model <E extends Record ,ID >
Returns:
the schema, or empty String if the schema is not specified.
name
Returns the name of the table or view.
Specified by:
name in interface Model <E extends Record ,ID >
Returns:
the name of the table or view.
qualifiedName
Returns the qualified name of the table or view, including the schema and escape characters where necessary.
Specified by:
qualifiedName in interface Model <E extends Record ,ID >
Returns:
the qualified name of the table or view, including the schema and escape characters where necessary.
isDefaultPrimaryKey
public boolean isDefaultPrimaryKey (@Nullable
ID pk)
Returns {code true} if the specified primary key represents a default value,
false otherwise.
This method is used to check if the primary key of the entity is a default value. This is useful when
determining if the entity is new or has been persisted before.
Specified by:
isDefaultPrimaryKey in interface Model <E extends Record ,ID >
Parameters:
pk - primary key to check.
Returns:
{code true} if the specified primary key represents a default value, false otherwise.
Since:
1.2
getValues
Extracts the values from the given record and maps them to the columns of the entity or projection.
Specified by:
getValues in interface Model <E extends Record ,ID >
Parameters:
record - the record to extract the values from.
Returns:
the values from the given record mapped to the columns of the entity or projection.
Throws:
PersistenceException - if an error occurs while extracting the values.
Since:
1.2
getValue
public Object getValue (@Nonnull
Column column,
@Nonnull
E record)
Extracts the value for the specified column from the given record.
Specified by:
getValue in interface Model <E extends Record ,ID >
Parameters:
column - the column to extract the value for.
record - the record to extract the value from.
Returns:
the value for the specified column from the given record.
Throws:
PersistenceException - if an error occurs while extracting the values.
Since:
1.2
toString
public final String toString ()
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
Specified by:
toString in class Record
Returns:
a string representation of this object
hashCode
public final int hashCode ()
Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
Specified by:
hashCode in class Record
Returns:
a hash code value for this object
equals
public final boolean equals (Object o)
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with
Objects::equals(Object,Object).
Specified by:
equals in class Record
Parameters:
o - the object with which to compare
Returns:
true if this object is the same as the o argument; false otherwise.
tableName
Returns the value of the
tableName record component.
Returns:
the value of the tableName record component
type
@Nonnull
public Class <E > type ()
Returns the value of the
type record component.
Specified by:
type in interface Model <E extends Record ,ID >
Returns:
the value of the type record component