Package org.fastnate.hibernate
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
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionContains the mapping from a class to its id in the database.private final org.fastnate.generator.context.GeneratorColumnThe column that contains the identifier of the type disciminator. -
Constructor Summary
ConstructorsConstructorDescriptionAnyMapping(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 ofAnyMapping. -
Method Summary
Modifier and TypeMethodDescriptionprivate static <A extends Annotation>
AfindAnnotation(org.fastnate.generator.context.AttributeAccessor attribute, Class<A> annotationClass) private org.fastnate.generator.statements.ColumnExpressionorg.fastnate.generator.context.GeneratorColumnThe column that contains the identifier of the type disciminator.getPredicate(T value) Builds a predicate to find the row with the given value.voidsetColumnValue(org.fastnate.generator.statements.TableStatement statement, T value) Sets the mapping value for the given value to the statement.
-
Field Details
-
column
private final org.fastnate.generator.context.GeneratorColumn columnThe column that contains the identifier of the type disciminator. -
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 ofAnyMapping.- Parameters:
context- the current generation contextattribute- the attribute that this mapping is attached tocontainerTable- the table that contains the discriminator columnattributeOverride- 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
-
getPredicate
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
Sets the mapping value for the given value to the statement.- Parameters:
statement- the statement of the current rowvalue- the value of the current row
-
getColumn
public org.fastnate.generator.context.GeneratorColumn getColumn()The column that contains the identifier of the type disciminator.
-