Class PrimitiveProperty<E,T>

Type Parameters:
E - The type of the container class
T - The type of the primitive
Direct Known Subclasses:
GeneratedIdProperty, VersionProperty

public class PrimitiveProperty<E,T> extends SingularProperty<E,T>
Describes a singular primitive property of an EntityClass. A primitive property is not only a Java primitive, but it includes all properties that are of a type that is easily mapped to an SQL expression using a ValueConverter. This includes:
Author:
Tobias Liefke, Andreas Penski
  • Constructor Details

    • PrimitiveProperty

      public PrimitiveProperty(GeneratorContext context, GeneratorTable table, AttributeAccessor attribute, jakarta.persistence.Column columnMetadata)
      Instantiates a new primitive property.
      Parameters:
      context - the current context
      table - the table that the column belongs to
      attribute - the attribute of the property
      columnMetadata - the column metadata
    • PrimitiveProperty

      public PrimitiveProperty(GeneratorContext context, GeneratorTable table, AttributeAccessor attribute, jakarta.persistence.Column columnMetadata, boolean autogenerated)
      Instantiates a new primitive property.
      Parameters:
      context - the current context
      table - the table that the column belongs to
      attribute - the attribute of the property
      columnMetadata - the column metadata
      autogenerated - true if the values of this property are not part of any insert statement because they are generated by the database
  • Method Details

    • addInsertExpression

      public void addInsertExpression(TableStatement statement, E entity)
      Description copied from class: Property
      Adds an expression according to the current value of the property for the given entity to an SQL insert statement.
      Overrides:
      addInsertExpression in class Property<E,T>
      Parameters:
      statement - the created statement
      entity - the inspected entity
    • getDefaultValue

      protected String getDefaultValue(AttributeAccessor attribute)
      Finds the default value from the given attribute.
      Parameters:
      attribute - the current attribute of the property
      Returns:
      the default value or null if none is set
      See Also:
    • getDialect

      protected GeneratorDialect getDialect()
      Resolves the current dialect from the context.
      Returns:
      the dialect of the current generation context
    • getExpression

      public ColumnExpression getExpression(E entity, boolean whereExpression)
      Description copied from class: Property
      Creates the expression for the current value of the given entity in SQL.
      Overrides:
      getExpression in class Property<E,T>
      Parameters:
      entity - the entity
      whereExpression - indicates that the expression is used in a "where" statement
      Returns:
      the expression for the value of this property or null if no exists
    • getPredicate

      public String getPredicate(E entity)
      Description copied from class: Property
      Creates an SQL predicate that references all entities that have the same value as the given entity. Used to reference entites by their (unique) properties or ids.
      Overrides:
      getPredicate in class Property<E,T>
      Parameters:
      entity - the entity
      Returns:
      the predicate for the value of that entity or null if no such expression is available
    • getContext

      public GeneratorContext getContext()
      The current context.
    • getTable

      public GeneratorTable getTable()
      The table of the column.
    • getColumn

      public GeneratorColumn getColumn()
      The column name in the table.
      Specified by:
      getColumn in class SingularProperty<E,T>
      Returns:
      the column name
    • isRequired

      public boolean isRequired()
      Indicates if the property required.
      Overrides:
      isRequired in class Property<E,T>
      Returns:
      true if the field is required
    • getConverter

      public ValueConverter<T> getConverter()
      The converter for any value.
    • getDefaultValue

      public String getDefaultValue()
      The default value.