All Implemented Interfaces:
Model <E,ID>
public class ModelImpl<E extends Data ,ID>
extends Object
implements Model <E,ID>
Represents the model of an entity.
Constructor Summary
Constructors
Method Summary
All Methods Instance Methods Concrete Methods
Returns all columns of this model, including columns of expanded relationships.
Returns the columns declared directly on this model.
void
Iterates over the values of the given columns for the supplied record.
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 type of the primary key.
Returns the schema, or empty String if the schema is not specified.
Returns the type of the entity or projection.
Methods inherited from class java.lang.Object
clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait
Constructor Details
ModelImpl
public ModelImpl (st.orm.core.template.impl.ModelImpl<E ,ID > core)
Method Details
schema
Returns the schema, or empty String if the schema is not specified.
Specified by:
schema in interface Model <E extends Data ,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 Data ,ID >
Returns:
the name of the table or view.
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 Data ,ID >
Parameters:
pk - primary key to check.
Returns:
{code true} if the specified primary key represents a default value, false otherwise.
Since:
1.2
type
Returns the type of the entity or projection.
Specified by:
type in interface Model <E extends Data ,ID >
Returns:
the type of the entity or projection.
primaryKeyType
Returns the type of the primary key.
Specified by:
primaryKeyType in interface Model <E extends Data ,ID >
Returns:
the type of the primary key.
columns
Returns all columns of this model, including columns of expanded relationships.
The returned list is deterministic and stable. Declared columns are processed in declaration order.
Foreign relationships are expanded depth-first at the position of the foreign-key column.
Expanded columns always correspond to physical columns of the parent record. Join keys come from the
parent row, not the referenced row.
Specified by:
columns in interface Model <E extends Data ,ID >
Returns:
all columns of this model, including expanded relations.
Since:
1.7
declaredColumns
Returns the columns declared directly on this model.
Relationship expansion is not applied. The returned list preserves declared order.
Index semantics: Column.index() refers to the index in columns() ,
not in this list.
Specified by:
declaredColumns in interface Model <E extends Data ,ID >
Returns:
the declared columns of this model.
Since:
1.8
forEachValue
Iterates over the values of the given columns for the supplied record.
Values are JDBC-ready. Conversions have already been applied.
Ordering requirement: columns must be ordered according to the model's
column order (usually columns() or declaredColumns() ).
Specified by:
forEachValue in interface Model <E extends Data ,ID >
Parameters:
columns - the columns to extract values for, ordered in model column order.
record - the record to extract values from.
consumer - receives each column and its extracted value.
Throws:
SqlTemplateException - if extraction fails.
Since:
1.8