Class EmbeddedProperty<E,T>

java.lang.Object
org.fastnate.generator.context.Property<E,T>
org.fastnate.generator.context.EmbeddedProperty<E,T>
Type Parameters:
E - The type of the container class (the entity or parent embeddable)
T - The type of the embeddable object

public class EmbeddedProperty<E,T> extends Property<E,T>
Handling of properties defined in Embeddables.
Author:
Tobias Liefke
  • Field Details

    • embeddedProperties

      private final Map<String,Property<? super T,?>> embeddedProperties
      The properties within the embedded object.
    • id

      private final boolean id
    • constructor

      private final Constructor<T> constructor
  • Constructor Details

    • EmbeddedProperty

      public EmbeddedProperty(EntityClass<?> entityClass, GeneratorTable table, AttributeAccessor attribute, Map<String,jakarta.persistence.AttributeOverride> surroundingAttributeOverrides, Map<String,jakarta.persistence.AssociationOverride> surroundingAssociationOverrides)
      Instantiates a new embedded property.
      Parameters:
      entityClass - the surrounding entity class
      table - the table that contains the attribute
      attribute - the attribute that contains the embedded object
      surroundingAttributeOverrides - the attribute overrides of the surrounding entity class or embedded property (if we are nested)
      surroundingAssociationOverrides - the association overrides of the surrounding entity class or embedded property (if we are nested)
  • 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
    • createPostInsertStatements

      public void createPostInsertStatements(StatementsWriter writer, E entity) throws IOException
      Description copied from class: Property
      Creates additional SQL statements that are necessary after this property is written (e.g. for mapping tables).
      Overrides:
      createPostInsertStatements in class Property<E,T>
      Parameters:
      writer - the target of the created statements
      entity - the inspected entity
      Throws:
      IOException - if the writer throws one
    • createPreInsertStatements

      public void createPreInsertStatements(StatementsWriter writer, E entity) throws IOException
      Description copied from class: Property
      Creates SQL statements that are necessary before this property is written (e.g. for updating the table generator).
      Overrides:
      createPreInsertStatements in class Property<E,T>
      Parameters:
      writer - the target of the created statements
      entity - the inspected entity
      Throws:
      IOException - if the writer throws an exception
    • findReferencedEntities

      public Collection<?> findReferencedEntities(E entity)
      Description copied from class: Property
      Finds all entities in the current property, that are referenced.
      Overrides:
      findReferencedEntities in class Property<E,T>
      Parameters:
      entity - the inspected entity
      Returns:
      all referenced entities
    • getInitializedValue

      public T getInitializedValue(E entity)
      Ensures that the property of the given entity is initialized. If the property has currently a null value, the property is assigned with a new object using the noargs constructor.
      Parameters:
      entity - the entity to initialize
      Returns:
      the instance of the embedded object
    • 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
    • isRequired

      public boolean isRequired()
      Description copied from class: Property
      Indicates if this property is an required field in the database (needs to exist when the insert statement is written).
      Overrides:
      isRequired in class Property<E,T>
      Returns:
      true if the field is required
    • isTableColumn

      public boolean isTableColumn()
      Description copied from class: Property
      Indicates that this property maps to a column from the parent table.
      Specified by:
      isTableColumn in class Property<E,T>
      Returns:
      true if Property.addInsertExpression(org.fastnate.generator.statements.TableStatement, E) will add the corresponding value to the given statement
    • getEmbeddedProperties

      public Map<String,Property<? super T,?>> getEmbeddedProperties()
      The properties within the embedded object.
    • isId

      public boolean isId()