Package org.fastnate.generator.context
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
Handling of properties defined in
Embeddables.- Author:
- Tobias Liefke
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Constructor<T> The properties within the embedded object.private final boolean -
Constructor Summary
ConstructorsConstructorDescriptionEmbeddedProperty(EntityClass<?> entityClass, GeneratorTable table, AttributeAccessor attribute, Map<String, jakarta.persistence.AttributeOverride> surroundingAttributeOverrides, Map<String, jakarta.persistence.AssociationOverride> surroundingAssociationOverrides) Instantiates a new embedded property. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddInsertExpression(TableStatement statement, E entity) Adds an expression according to the current value of the property for the given entity to an SQL insert statement.voidcreatePostInsertStatements(StatementsWriter writer, E entity) Creates additional SQL statements that are necessary after this property is written (e.g. for mapping tables).voidcreatePreInsertStatements(StatementsWriter writer, E entity) Creates SQL statements that are necessary before this property is written (e.g. for updating the table generator).Collection<?> findReferencedEntities(E entity) Finds all entities in the current property, that are referenced.The properties within the embedded object.getInitializedValue(E entity) Ensures that the property of the given entity is initialized.getPredicate(E entity) Creates an SQL predicate that references all entities that have the same value as the given entity.booleanisId()booleanIndicates if this property is an required field in the database (needs to exist when the insert statement is written).booleanIndicates that this property maps to a column from the parent table.Methods inherited from class org.fastnate.generator.context.Property
failIfRequired, generatePendingStatements, getAttribute, getExpression, getName, getType, getValue, isComposition, setValue, toString
-
Field Details
-
embeddedProperties
The properties within the embedded object. -
id
private final boolean id -
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 classtable- the table that contains the attributeattribute- the attribute that contains the embedded objectsurroundingAttributeOverrides- 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
Description copied from class:PropertyAdds an expression according to the current value of the property for the given entity to an SQL insert statement.- Overrides:
addInsertExpressionin classProperty<E,T> - Parameters:
statement- the created statemententity- the inspected entity
-
createPostInsertStatements
Description copied from class:PropertyCreates additional SQL statements that are necessary after this property is written (e.g. for mapping tables).- Overrides:
createPostInsertStatementsin classProperty<E,T> - Parameters:
writer- the target of the created statementsentity- the inspected entity- Throws:
IOException- if the writer throws one
-
createPreInsertStatements
Description copied from class:PropertyCreates SQL statements that are necessary before this property is written (e.g. for updating the table generator).- Overrides:
createPreInsertStatementsin classProperty<E,T> - Parameters:
writer- the target of the created statementsentity- the inspected entity- Throws:
IOException- if the writer throws an exception
-
findReferencedEntities
Description copied from class:PropertyFinds all entities in the current property, that are referenced.- Overrides:
findReferencedEntitiesin classProperty<E,T> - Parameters:
entity- the inspected entity- Returns:
- all referenced entities
-
getInitializedValue
Ensures that the property of the given entity is initialized. If the property has currently anullvalue, 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
Description copied from class:PropertyCreates 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:
getPredicatein classProperty<E,T> - Parameters:
entity- the entity- Returns:
- the predicate for the value of that entity or
nullif no such expression is available
-
isRequired
public boolean isRequired()Description copied from class:PropertyIndicates if this property is an required field in the database (needs to exist when the insert statement is written).- Overrides:
isRequiredin classProperty<E,T> - Returns:
trueif the field is required
-
isTableColumn
public boolean isTableColumn()Description copied from class:PropertyIndicates that this property maps to a column from the parent table.- Specified by:
isTableColumnin classProperty<E,T> - Returns:
trueifProperty.addInsertExpression(org.fastnate.generator.statements.TableStatement, E)will add the corresponding value to the given statement
-
getEmbeddedProperties
The properties within the embedded object. -
isId
public boolean isId()
-