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 override,
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(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 static GeneratorColumn |
buildValueColumn(GeneratorTable table,
javax.persistence.AssociationOverride override,
AttributeAccessor attribute,
String defaultColumnName)
Builds the column that contains the value for the collection / map.
|
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<SingularProperty<T,?>> |
getEmbeddedProperties()
Contains all properties of an embedded element collection.
|
Map<String,SingularProperty<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 override, int valueClassParamIndex)
sourceClass - the description of the current inspected class that contains this propertyattribute - accessor to the represented attributeoverride - the configured assocation overridevalueClassParamIndex - 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 GeneratorColumn buildValueColumn(GeneratorTable table, javax.persistence.AssociationOverride override, AttributeAccessor attribute, String defaultColumnName)
table - the collection tableoverride - contains optional override optionsattribute - the inspected attributedefaultColumnName - the default column nameprotected 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(Class<?> targetType)
targetType - 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()
@Generated(value="lombok") public GeneratorContext getContext()
@Generated(value="lombok") public GeneratorDialect getDialect()
@Generated(value="lombok") public List<SingularProperty<T,?>> getEmbeddedProperties()
@Generated(value="lombok") public Map<String,SingularProperty<T,?>> getEmbeddedPropertiesByName()
@Generated(value="lombok") public List<EntityProperty<T,?>> getRequiredEmbeddedProperties()
@Generated(value="lombok") public String getMappedId()
@Generated(value="lombok") public GeneratorTable getTable()
@Generated(value="lombok") public GeneratorColumn getIdColumn()
@Generated(value="lombok") public boolean isComposition()
CascadeType, we should remove the target entities when the current
entity is removed.
Always true for ElementCollections.@Generated(value="lombok") public String getMappedBy()
@Generated(value="lombok") public Property<T,?> getInverseProperty()
PluralProperty (it the relationship is a ManyToMany) or an
EntityProperty (if the relationship is a OneToMany.@Generated(value="lombok") public boolean isUseTargetTable()
@Generated(value="lombok") public GeneratorColumn getValueColumn()
@Generated(value="lombok") public Class<T> getValueClass()
@Generated(value="lombok") public Constructor<T> getValueConstructor()
@Generated(value="lombok") public boolean isEntityReference()
@Generated(value="lombok") public EntityClass<T> getValueEntityClass()
@Generated(value="lombok") public ValueConverter<T> getValueConverter()
null if not a primitive value.@Generated(value="lombok") public AnyMapping<T> getAnyMapping()
ManyToAny is used.Copyright © 2020 fastnate.org. All rights reserved.