E
- The type of the container entityT
- The type of the target entitypublic class EntityProperty<E,T> extends SingularProperty<E,T>
EntityClass
that references another entity.Modifier and Type | Class and Description |
---|---|
private static class |
EntityProperty.MappingInformation
Helper for evaluating correct mapping information from the annotations.
|
Modifier and Type | Field and Description |
---|---|
private AnyMapping<T> |
anyMapping
Contains information about an addition class column, if
Any is used. |
private GeneratorColumn |
column
The name of the join column.
|
private boolean |
composition
Indicates that, according to the
CascadeType , we should remove the target entity when the current entity
is removed. |
private GeneratorContext |
context
The current context.
|
private String |
idField
The name of the id for referencing an embedded id.
|
private Property<T,?> |
inverseProperty
The opposite property of a bidirectional mapping.
|
private String |
mappedBy
The optional name of a property in the target type, that owns the relationship.
|
private boolean |
required
Indicates, that this property needs a value.
|
private EntityClass<T> |
targetClass
The description of the type of this property.
|
Constructor and Description |
---|
EntityProperty(GeneratorContext context,
GeneratorTable containerTable,
AttributeAccessor attribute,
javax.persistence.AssociationOverride override)
Creates a new instance of
EntityProperty . |
Modifier and Type | Method and Description |
---|---|
void |
addInsertExpression(TableStatement statement,
E entity)
Adds an expression according to the current value of the property for the given entity to an SQL insert
statement.
|
Collection<?> |
findReferencedEntities(E entity)
Finds all entities in the current property, that are referenced.
|
void |
generatePendingStatements(StatementsWriter writer,
E entity,
Object writtenEntity,
Object... arguments)
Generates the update statements for an entity that are required after another entity was generated.
|
AnyMapping<T> |
getAnyMapping()
Contains information about an addition class column, if
Any is used. |
GeneratorColumn |
getColumn()
The name of the join column.
|
GeneratorContext |
getContext()
The current context.
|
ColumnExpression |
getExpression(E entity,
boolean whereExpression)
Creates the expression for the current value of the given entity in SQL.
|
String |
getIdField()
The name of the id for referencing an embedded id.
|
Property<T,?> |
getInverseProperty()
The opposite property of a bidirectional mapping.
|
String |
getMappedBy()
The optional name of a property in the target type, that owns the relationship.
|
String |
getPredicate(E entity)
Creates an SQL predicate that references all entities that have the same value as the given entity.
|
EntityClass<T> |
getTargetClass()
The description of the type of this property.
|
boolean |
isComposition()
Indicates that, according to the
CascadeType , we should remove the target entity when the current entity
is removed. |
(package private) static boolean |
isEntityProperty(AttributeAccessor attribute)
Indicates that the given attribute references an entity and may be used by an
EntityProperty . |
boolean |
isRequired()
Indicates, that this property needs a value.
|
boolean |
isTableColumn()
Indicates that this property maps to a column from the parent table.
|
(package private) void |
setInverseProperty(Property<T,?> inverseProperty)
The opposite property of a bidirectional mapping.
|
createPostInsertStatements, createPreInsertStatements, failIfRequired, getAttribute, getName, getType, getValue, isComposition, setValue, toString
private final GeneratorContext context
private final EntityClass<T> targetClass
null
for attributes defined as type Any
.private final boolean required
private final boolean composition
CascadeType
, we should remove the target entity when the current entity
is removed.private final String mappedBy
OneToOne.mappedBy()
private Property<T,?> inverseProperty
private final GeneratorColumn column
private final String idField
private final AnyMapping<T> anyMapping
Any
is used.public EntityProperty(GeneratorContext context, GeneratorTable containerTable, AttributeAccessor attribute, @Nullable javax.persistence.AssociationOverride override)
EntityProperty
.context
- the generator context.containerTable
- the table that contains our columnattribute
- the accessor of the attributeoverride
- optional AttributeOverride
configuration.static boolean isEntityProperty(AttributeAccessor attribute)
EntityProperty
.attribute
- accessor of the attribute to checktrue
if an EntityProperty
may be created for the given attributepublic void addInsertExpression(TableStatement statement, E entity)
Property
addInsertExpression
in class Property<E,T>
statement
- the created statemententity
- the inspected entitypublic Collection<?> findReferencedEntities(E entity)
Property
findReferencedEntities
in class Property<E,T>
entity
- the inspected entitypublic void generatePendingStatements(StatementsWriter writer, E entity, Object writtenEntity, Object... arguments) throws IOException
Property
EntityClass.markPendingUpdates(E, V, org.fastnate.generator.context.Property<V, ?>, java.lang.Object...)
was called before for writtenEntity
generatePendingStatements
in class Property<E,T>
writer
- the target of the generated statementsentity
- the entity that needs to be updatedwrittenEntity
- the entity that exists now in the databasearguments
- additional arguments that where given to markPendingUpdatesIOException
- if the writer throws onepublic ColumnExpression getExpression(E entity, boolean whereExpression)
Property
getExpression
in class Property<E,T>
entity
- the entitywhereExpression
- indicates that the expression is used in a "where" statementnull
if no existspublic String getPredicate(E entity)
Property
getPredicate
in class Property<E,T>
entity
- the entitynull
if no such expression is availablepublic boolean isTableColumn()
Property
isTableColumn
in class SingularProperty<E,T>
true
if Property.addInsertExpression(org.fastnate.generator.statements.TableStatement, E)
will add the corresponding value to the given statement@Generated(value="lombok") public GeneratorContext getContext()
@Generated(value="lombok") public EntityClass<T> getTargetClass()
null
for attributes defined as type Any
.@Generated(value="lombok") public boolean isRequired()
isRequired
in class Property<E,T>
true
if the field is required@Generated(value="lombok") public boolean isComposition()
CascadeType
, we should remove the target entity when the current entity
is removed.@Generated(value="lombok") public String getMappedBy()
OneToOne.mappedBy()
@Generated(value="lombok") public Property<T,?> getInverseProperty()
@Generated(value="lombok") public GeneratorColumn getColumn()
getColumn
in class SingularProperty<E,T>
@Generated(value="lombok") public String getIdField()
@Generated(value="lombok") public AnyMapping<T> getAnyMapping()
Any
is used.@Generated(value="lombok") void setInverseProperty(Property<T,?> inverseProperty)
Copyright © 2022 fastnate.org. All rights reserved.