Class AnyMapping<T>

java.lang.Object
org.fastnate.hibernate.AnyMapping<T>
Type Parameters:
T - the type of the attribute that this mapping is attached to

public class AnyMapping<T> extends Object
A column that is responsible to store the information for references to arbitrary entity types that are stored in the same attribute.
Author:
Tobias Liefke
See Also:
  • Any
  • ManyToAny
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Map<Class<?>,org.fastnate.generator.statements.ColumnExpression>
    Contains the mapping from a class to its id in the database.
    private final org.fastnate.generator.context.GeneratorColumn
    The column that contains the identifier of the type disciminator.
  • Constructor Summary

    Constructors
    Constructor
    Description
    AnyMapping(org.fastnate.generator.context.GeneratorContext context, org.fastnate.generator.context.AttributeAccessor attribute, org.fastnate.generator.context.GeneratorTable containerTable, jakarta.persistence.AttributeOverride attributeOverride)
    Creates a new instance of AnyMapping.
  • Method Summary

    Modifier and Type
    Method
    Description
    private static <A extends Annotation>
    A
    findAnnotation(org.fastnate.generator.context.AttributeAccessor attribute, Class<A> annotationClass)
     
    private org.fastnate.generator.statements.ColumnExpression
    findDesc(T entity)
     
    org.fastnate.generator.context.GeneratorColumn
    The column that contains the identifier of the type disciminator.
    getPredicate(T value)
    Builds a predicate to find the row with the given value.
    void
    setColumnValue(org.fastnate.generator.statements.TableStatement statement, T value)
    Sets the mapping value for the given value to the statement.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • column

      private final org.fastnate.generator.context.GeneratorColumn column
      The column that contains the identifier of the type disciminator.
    • anyClasses

      private final Map<Class<?>,org.fastnate.generator.statements.ColumnExpression> anyClasses
      Contains the mapping from a class to its id in the database.
  • Constructor Details

    • AnyMapping

      public AnyMapping(org.fastnate.generator.context.GeneratorContext context, org.fastnate.generator.context.AttributeAccessor attribute, org.fastnate.generator.context.GeneratorTable containerTable, jakarta.persistence.AttributeOverride attributeOverride)
      Creates a new instance of AnyMapping.
      Parameters:
      context - the current generation context
      attribute - the attribute that this mapping is attached to
      containerTable - the table that contains the discriminator column
      attributeOverride - contains the optional attribute overrides for the discriminator column
  • Method Details

    • findAnnotation

      private static <A extends Annotation> A findAnnotation(org.fastnate.generator.context.AttributeAccessor attribute, Class<A> annotationClass)
    • findDesc

      private org.fastnate.generator.statements.ColumnExpression findDesc(T entity)
    • getPredicate

      public String getPredicate(T value)
      Builds a predicate to find the row with the given value. Does only work with an additional predicate for the id.
      Parameters:
      value - the current value to find as row
      Returns:
      the predicate to find all rows with the same type of value
    • setColumnValue

      public void setColumnValue(org.fastnate.generator.statements.TableStatement statement, T value)
      Sets the mapping value for the given value to the statement.
      Parameters:
      statement - the statement of the current row
      value - the value of the current row
    • getColumn

      public org.fastnate.generator.context.GeneratorColumn getColumn()
      The column that contains the identifier of the type disciminator.