Module storm.java

Class ModelImpl<E extends Data,ID>

java.lang.Object
st.orm.template.impl.ModelImpl<E,ID>
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 Details

    • ModelImpl

      public ModelImpl(st.orm.core.template.impl.ModelImpl<E,ID> core)
  • Method Details

    • schema

      public String 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

      public String 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

      public Class<E> 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

      public Class<ID> 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

      public List<Column> 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

      public List<Column> 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

      public void forEachValue(List<Column> columns, E record, BiConsumer<Column,Object> consumer) throws SqlTemplateException
      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