Class CollectionProperty<E,T>

Type Parameters:
E - The type of the container entity
T - The type of the entity inside of the collection

public class CollectionProperty<E,T> extends PluralProperty<E,Collection<T>,T>
Describes a property of an EntityClass that contains more than one value.
Author:
Tobias Liefke
  • Field Details

    • orderColumn

      private final GeneratorColumn orderColumn
      The name of the column that saves the order of the entries in the collection.
  • Constructor Details

    • CollectionProperty

      public CollectionProperty(EntityClass<?> sourceClass, AttributeAccessor attribute, jakarta.persistence.AssociationOverride associationOverride, jakarta.persistence.AttributeOverride attributeOverride)
      Creates a new collection property.
      Parameters:
      sourceClass - the description of the current inspected class that contains this property
      attribute - accessor to the represented attribute
      associationOverride - the configured assocation override
      attributeOverride - the configured attribute override, if we reference an ElementCollection
  • Method Details

    • isCollectionProperty

      public static boolean isCollectionProperty(AttributeAccessor attribute)
      Indicates that the given attribute references a collection and may be used by an CollectionProperty.
      Parameters:
      attribute - the attribute to check
      Returns:
      true if an CollectionProperty may be created for the given attribute
    • 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,Collection<T>>
      Parameters:
      writer - the target of the created statements
      entity - the inspected entity
      Throws:
      IOException - if the writer throws one
    • 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,Collection<T>>
      Parameters:
      entity - the inspected entity
      Returns:
      all referenced entities
    • getKeyColumn

      protected GeneratorColumn getKeyColumn()
      Description copied from class: PluralProperty
      An optional column that contains the index / key of the values.
      Specified by:
      getKeyColumn in class PluralProperty<E,Collection<T>,T>
      Returns:
      the key column for map properties resp. the index column for list properties
    • getValue

      public Collection<T> getValue(E entity)
      Description copied from class: Property
      Resolves the current value for this property on the given entity.
      Overrides:
      getValue in class Property<E,Collection<T>>
      Parameters:
      entity - the entity to inspect
      Returns:
      the value, null if entity is null
    • getOrderColumn

      public GeneratorColumn getOrderColumn()
      The name of the column that saves the order of the entries in the collection.