Interface EntityPropertyType<ENTITY,BASIC>

Type Parameters:
ENTITY - the entity type that contains this property
BASIC - the basic type that represents the property's value
All Known Implementing Classes:
AssignedIdPropertyType, DefaultPropertyType, GeneratedIdPropertyType, TenantIdPropertyType, VersionPropertyType

public interface EntityPropertyType<ENTITY,BASIC>
Describes a property of an entity class that maps to a database column.

This interface defines methods for accessing property metadata, such as property name, column name, and various property characteristics (ID, version, etc.). It also provides methods for creating property instances and copying property values.

Implementations of this interface are typically generated at compile time by the Doma annotation processor based on Entity annotated classes.

This instance is not required to be thread safe.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    copy(ENTITY dest, ENTITY src)
    Copies the value of this property from one entity instance to another.
    Creates a property instance for this property type.
    Returns the database column name that this property maps to.
    Returns the database column name with naming convention applied.
    Returns the database column name with both naming convention and quotation marks applied.
    Returns the database column name with optional quotation marks applied.
    Returns the name of this property.
    boolean
    Determines whether this property represents a primary key (identifier).
    boolean
    Determines whether the column mapped to this property is included in SQL INSERT statements.
    boolean
    Determines whether quotation marks are required for the column name.
    boolean
    Determines whether this property represents a tenant identifier for multi-tenancy.
    boolean
    Determines whether the column mapped to this property is included in SQL UPDATE statements.
    boolean
    Determines whether this property represents a version column for optimistic locking.
  • Method Details

    • getName

      String getName()
      Returns the name of this property.

      The property name typically corresponds to the field or method name in the entity class that is mapped to a database column.

      Returns:
      the property name
    • getColumnName

      String getColumnName()
      Returns the database column name that this property maps to.

      The column name is determined based on the Column annotation if present, or derived from the property name using the entity's naming convention.

      Returns:
      the database column name
      See Also:
    • getColumnName

      String getColumnName(Function<String,String> quoteFunction)
      Returns the database column name with optional quotation marks applied.

      This method allows customizing how quotation marks are applied to the column name, which is useful when generating SQL for different database dialects.

      Parameters:
      quoteFunction - the function that applies quotation marks to the column name
      Returns:
      the column name with quotation marks applied as specified
      See Also:
    • getColumnName

      String getColumnName(BiFunction<NamingType,String,String> namingFunction)
      Returns the database column name with naming convention applied.

      This method allows customizing how naming conventions are applied to the column name, which is useful when generating SQL for different database naming styles.

      Parameters:
      namingFunction - the function that applies naming convention to the column name
      Returns:
      the column name with naming convention applied
      See Also:
    • getColumnName

      String getColumnName(BiFunction<NamingType,String,String> namingFunction, Function<String,String> quoteFunction)
      Returns the database column name with both naming convention and quotation marks applied.

      This method combines the functionality of getColumnName(BiFunction) and getColumnName(Function) to apply both naming conventions and quotation marks to the column name.

      Parameters:
      namingFunction - the function that applies naming convention to the column name
      quoteFunction - the function that applies quotation marks to the column name
      Returns:
      the column name with both naming convention and quotation marks applied
      See Also:
    • isQuoteRequired

      boolean isQuoteRequired()
      Determines whether quotation marks are required for the column name.

      This method indicates if the column name should be quoted in SQL statements, which is typically needed for reserved words or column names with special characters.

      Returns:
      true if quotation marks are required, false otherwise
      See Also:
    • isId

      boolean isId()
      Determines whether this property represents a primary key (identifier).

      This method indicates if the property is annotated with Id, which marks it as a primary key column in the database table.

      Returns:
      true if this property is a primary key, false otherwise
      See Also:
    • isVersion

      boolean isVersion()
      Determines whether this property represents a version column for optimistic locking.

      This method indicates if the property is annotated with Version, which marks it as a version column used for optimistic concurrency control.

      Returns:
      true if this property is a version column, false otherwise
      See Also:
    • isTenantId

      boolean isTenantId()
      Determines whether this property represents a tenant identifier for multi-tenancy.

      This method indicates if the property is annotated with TenantId, which marks it as a tenant identifier column used for multi-tenant database access.

      Returns:
      true if this property is a tenant identifier, false otherwise
      See Also:
    • isInsertable

      boolean isInsertable()
      Determines whether the column mapped to this property is included in SQL INSERT statements.

      This method indicates if the property should be included when generating INSERT statements. Properties may be excluded from INSERT statements if they are auto-generated or should not be explicitly set.

      Returns:
      true if the property is included in SQL INSERT statements, false otherwise
      See Also:
    • isUpdatable

      boolean isUpdatable()
      Determines whether the column mapped to this property is included in SQL UPDATE statements.

      This method indicates if the property should be included when generating UPDATE statements. Properties may be excluded from UPDATE statements if they are read-only or should not be modified after creation.

      Returns:
      true if the property is included in SQL UPDATE statements, false otherwise
      See Also:
    • createProperty

      Property<ENTITY,BASIC> createProperty()
      Creates a property instance for this property type.

      The created property instance can be used to get and set property values on entity instances, as well as to convert between entity property values and database column values.

      Returns:
      a new property instance
      See Also:
    • copy

      void copy(ENTITY dest, ENTITY src)
      Copies the value of this property from one entity instance to another.

      This method performs a deep copy of the property value. However, it does not copy JDBC-specific objects such as Blob, Clob, or SQLXML.

      This method is useful for creating copies of entity instances while preserving the values of their properties.

      Parameters:
      dest - the entity instance that is the copy destination
      src - the entity instance that is the copy source