E - The type of the container classC - The type of the collection or mapT - The type of the elements in the collectionpublic abstract class PluralProperty<E,C,T> extends Property<E,C>
MapProperty and CollectionProperty.| Constructor and Description |
|---|
PluralProperty(EntityClass<?> sourceClass,
AttributeAccessor attribute,
javax.persistence.AssociationOverride associationOverride,
javax.persistence.AttributeOverride attributeOverride,
int valueClassParamIndex)
Creates a new property.
|
| 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.
|
protected void |
buildEmbeddedProperties(EntityClass<?> sourceClass,
Class<?> targetType)
Builds the embedded properties of this property.
|
protected static String |
buildIdColumn(AttributeAccessor attribute,
javax.persistence.AssociationOverride override,
javax.persistence.CollectionTable collectionMetadata,
String defaultIdColumn)
Builds the name of the column that contains the ID of the entity for the given attribute.
|
protected void |
createDirectValueStatement(StatementsWriter writer,
E entity,
ColumnExpression sourceId,
ColumnExpression key,
T value)
Creates the statements for a (not embeddable) value from the collection.
|
protected ColumnExpression |
createValueExpression(E entity,
ColumnExpression sourceId,
T value,
ColumnExpression key)
Creates a SQL expression for a value of the collection, as long as it is not embedded.
|
protected void |
createValueStatement(StatementsWriter writer,
E entity,
ColumnExpression sourceId,
ColumnExpression key,
T value)
Adds a value statement to the list of collection statements.
|
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
ManyToAny is used. |
GeneratorContext |
getContext()
The current context.
|
GeneratorDialect |
getDialect()
The current database dialect, as defined in the context.
|
List<Property<T,?>> |
getEmbeddedProperties()
Contains all properties of an embedded element collection.
|
Map<String,Property<T,?>> |
getEmbeddedPropertiesByName()
Contains all properties of an embedded element collection by their name.
|
GeneratorColumn |
getIdColumn()
The column that contains the id of the entity.
|
Property<T,?> |
getInverseProperty()
The opposite property of a bidirectional mapping.
|
protected abstract GeneratorColumn |
getKeyColumn()
An optional column that contains the index / key of the values.
|
String |
getMappedBy()
Indicates that this property is defined by another property on the target type.
|
String |
getMappedId()
The property to use, if an id is embedded.
|
protected static <T> Class<T> |
getPropertyArgument(AttributeAccessor attribute,
Class<T> explicitClass,
int argumentIndex)
Inspects the given attribute and searches for a generic type argument.
|
List<EntityProperty<T,?>> |
getRequiredEmbeddedProperties()
Contains all properties of an embedded element collection which reference a required entity.
|
GeneratorTable |
getTable()
The modified table.
|
Class<T> |
getValueClass()
The class of the value of the collection.
|
GeneratorColumn |
getValueColumn()
The column that contains the value (or the id of the value).
|
Constructor<T> |
getValueConstructor()
The noargs constructor for the values of the collection.
|
ValueConverter<T> |
getValueConverter()
The converter for the value of the collection,
null if not a primitive value. |
EntityClass<T> |
getValueEntityClass()
|
protected static boolean |
hasPluralAnnotation(AttributeAccessor attribute)
Indicates, that the given attribute has an annotation that indicates a plural property.
|
boolean |
isComposition()
Indicates that, according to the
CascadeType, we should remove the target entities when the current
entity is removed. |
boolean |
isEmbedded()
Indicates that this propery is a
ElementCollection that references Embeddables. |
boolean |
isEntityReference()
Indicates that entities are referenced by the collection.
|
boolean |
isRequired()
Indicates if this property is an required field in the database (needs to exist when the insert statement is
written).
|
boolean |
isTableColumn()
Indicates that this property maps to a column from the parent table.
|
boolean |
isUseTargetTable()
Indicates to use a column of the target table.
|
T |
newElement()
Tries to create a new instance of an element using the parameter-less constructor.
|
createPostInsertStatements, createPreInsertStatements, failIfRequired, findReferencedEntities, getAttribute, getExpression, getName, getPredicate, getType, getValue, isComposition, setValue, toStringpublic PluralProperty(EntityClass<?> sourceClass, AttributeAccessor attribute, javax.persistence.AssociationOverride associationOverride, javax.persistence.AttributeOverride attributeOverride, int valueClassParamIndex)
sourceClass - the description of the current inspected class that contains this propertyattribute - accessor to the represented attributeassociationOverride - the configured assocation overrideattributeOverride - the configured attribute override, if we reference an ElementCollectionvalueClassParamIndex - the index of the value argument in the collection class (0 for collection, 1 for map)protected static String buildIdColumn(AttributeAccessor attribute, javax.persistence.AssociationOverride override, javax.persistence.CollectionTable collectionMetadata, String defaultIdColumn)
attribute - the accessor for the inspected attributeoverride - contains optional override optionscollectionMetadata - the default join columndefaultIdColumn - the default name for the column, if joinColumn is empty or nullprotected static <T> Class<T> getPropertyArgument(AttributeAccessor attribute, Class<T> explicitClass, int argumentIndex)
attribute - the attribute to inspectexplicitClass - an explicit class to use, if the metadata specified oneargumentIndex - the index of the argument, for maps there are two: the key and the valueprotected static boolean hasPluralAnnotation(AttributeAccessor attribute)
attribute - the attribute to checktrue if one of the plural annotations is defined for the attributepublic void addInsertExpression(TableStatement statement, E entity)
PropertyaddInsertExpression in class Property<E,C>statement - the created statemententity - the inspected entityprotected void buildEmbeddedProperties(EntityClass<?> sourceClass, Class<?> targetType)
sourceClass - the class that contains our propertytargetType - the target typeprotected void createDirectValueStatement(StatementsWriter writer, E entity, ColumnExpression sourceId, ColumnExpression key, T value) throws IOException
writer - the target of created statementsentity - the entity that contains the collection resp. map.sourceId - the ID of the current entitykey - the value of the getKeyColumn() - either the index or the map keyvalue - the current value in the collectionIOException - if the writer throws oneprotected ColumnExpression createValueExpression(E entity, ColumnExpression sourceId, T value, ColumnExpression key)
entity - the entity that contains the collectionsourceId - the id of the entity as SQL expressionkey - the key/index of the entity in the collection as SQL expressionvalue - the value that is writtennull if the insert is still pendingprotected void createValueStatement(StatementsWriter writer, E entity, ColumnExpression sourceId, ColumnExpression key, T value) throws IOException
writer - the target of the created statementsentity - the entity that contains the collectionsourceId - the id of the entity as SQL expressionkey - the key/index of the entity in the collection as SQL expressionvalue - the value that is writtenIOException - if the writer throws onepublic void generatePendingStatements(StatementsWriter writer, E entity, Object writtenEntity, Object... arguments) throws IOException
PropertyEntityClass.markPendingUpdates(E, V, org.fastnate.generator.context.Property<V, ?>, java.lang.Object...) was called before for writtenEntitygeneratePendingStatements in class Property<E,C>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 oneprotected abstract GeneratorColumn getKeyColumn()
public boolean isEmbedded()
ElementCollection that references Embeddables.getEmbeddedProperties() returns a list of propertiespublic boolean isRequired()
PropertyisRequired in class Property<E,C>true if the field is requiredpublic boolean isTableColumn()
PropertyisTableColumn in class Property<E,C>true if Property.addInsertExpression(org.fastnate.generator.statements.TableStatement, E) will add the corresponding value to the given statementpublic T newElement()
public GeneratorContext getContext()
public GeneratorDialect getDialect()
public List<Property<T,?>> getEmbeddedProperties()
public Map<String,Property<T,?>> getEmbeddedPropertiesByName()
public List<EntityProperty<T,?>> getRequiredEmbeddedProperties()
public String getMappedId()
public GeneratorTable getTable()
public GeneratorColumn getIdColumn()
public boolean isComposition()
CascadeType, we should remove the target entities when the current
entity is removed.
Always true for ElementCollections.public String getMappedBy()
public Property<T,?> getInverseProperty()
PluralProperty (it the relationship is a ManyToMany) or an
EntityProperty (if the relationship is a OneToMany.public boolean isUseTargetTable()
public GeneratorColumn getValueColumn()
public Constructor<T> getValueConstructor()
public boolean isEntityReference()
public EntityClass<T> getValueEntityClass()
public ValueConverter<T> getValueConverter()
null if not a primitive value.public AnyMapping<T> getAnyMapping()
ManyToAny is used.Copyright © 2026 fastnate.org. All rights reserved.