E - The type of the container classC - The type of the collection of 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 valueArgumentIndex)
Creates a new property.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addInsertExpression(E entity,
InsertStatement statement)
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 String |
buildIdColumn(AttributeAccessor attribute,
javax.persistence.AssociationOverride override,
javax.persistence.JoinTable joinTable,
javax.persistence.CollectionTable tableMetadata,
String defaultIdColumn)
Builds the name of the column that contains the ID of the entity for the given attribute.
|
protected static String |
buildTableName(AttributeAccessor attribute,
javax.persistence.AssociationOverride override,
javax.persistence.JoinTable joinTable,
javax.persistence.CollectionTable collectionTable,
String defaultTableName)
Builds the name of the table of the association for the given field.
|
protected static String |
buildTableName(javax.persistence.CollectionTable tableMetadata,
String defaultTableName)
Builds the name of the table of the association for the given field.
|
protected static String |
buildValueColumn(AttributeAccessor attribute,
String defaultValueColumn)
Builds the name of the column that contains the value for the collection / map.
|
protected EntityStatement |
createDirectValueStatement(E entity,
String sourceId,
String key,
T value)
Creates the statements for a (not embeddable) value from the collection.
|
protected String |
createValueExpression(E entity,
String sourceId,
T value,
String key)
Creates a SQL expression for a value of the collection, as long as it is not embedded.
|
protected EntityStatement |
createValueStatement(E entity,
String sourceId,
String key,
T value)
Adds a value statement to the list of collection statements.
|
List<EntityStatement> |
generatePendingStatements(E entity,
Object writtenEntity,
Object... arguments)
Generates the update statements for an entity that are required after another entity was generated.
|
GeneratorContext |
getContext()
The current context.
|
List<SingularProperty<T,?>> |
getEmbeddedProperties()
Contains all properties of an embedded element collection.
|
String |
getIdColumn()
The name of the column that contains the id of the entity.
|
protected abstract String |
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.
|
String |
getTable()
The name of the modified table.
|
Class<T> |
getValueClass()
The class of the value of the collection.
|
String |
getValueColumn()
The name of the column that contains the value (or the id of the value).
|
ValueConverter<T> |
getValueConverter()
The converter for the value of the collection,
null if not a primitive value. |
EntityClass<T> |
getValueEntityClass()
The description of the
valueClass, null if not an entity. |
boolean |
isEmbedded()
Indicates that this propery is a
ElementCollection that references Embeddables. |
protected 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.
|
createPostInsertStatements, createPreInsertStatements, failIfRequired, findReferencedEntities, getAttribute, getExpression, getName, getPredicate, getValue, setValue, toStringpublic PluralProperty(EntityClass<?> sourceClass, AttributeAccessor attribute, javax.persistence.AssociationOverride override, int valueArgumentIndex)
sourceClass - the description of the current inspected class that contains this propertyattribute - accessor to the represented attributeoverride - the configured assocation overridevalueArgumentIndex - 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 String buildIdColumn(AttributeAccessor attribute, javax.persistence.AssociationOverride override, javax.persistence.JoinTable joinTable, javax.persistence.CollectionTable tableMetadata, String defaultIdColumn)
attribute - the inspected attributeoverride - contains optional override optionsjoinTable - the optional join table datetableMetadata - the optionaldefaultIdColumn - the default name for the column, if joinColumn is empty or nullprotected static String buildTableName(AttributeAccessor attribute, javax.persistence.AssociationOverride override, javax.persistence.JoinTable joinTable, javax.persistence.CollectionTable collectionTable, String defaultTableName)
attribute - the inspected fieldoverride - contains optional override optionsjoinTable - the optional join tablecollectionTable - the optional metadata of the tabledefaultTableName - the default name for the tableprotected static String buildTableName(javax.persistence.CollectionTable tableMetadata, String defaultTableName)
tableMetadata - the current metadata of the fielddefaultTableName - the default name for the tableprotected static String buildValueColumn(AttributeAccessor attribute, String defaultValueColumn)
attribute - the inspected attributedefaultValueColumn - the default 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 valuepublic void addInsertExpression(E entity, InsertStatement statement)
PropertyaddInsertExpression in class Property<E,C>entity - the inspected entitystatement - the created statementprotected void buildEmbeddedProperties(Class<?> targetType)
targetType - the target typeprotected EntityStatement createDirectValueStatement(E entity, String sourceId, String key, T value)
entity - 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 collectionprotected String createValueExpression(E entity, String sourceId, T value, String 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 EntityStatement createValueStatement(E entity, String sourceId, String key, T value)
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 pendingpublic List<EntityStatement> generatePendingStatements(E entity, Object writtenEntity, Object... arguments)
PropertyEntityClass.markPendingUpdates(E, V, org.fastnate.generator.context.Property<V, ?>, java.lang.Object...) was called before for writtenEntitygeneratePendingStatements in class Property<E,C>entity - the entity that needs to be updatedwrittenEntity - the entity that exists now in the databasearguments - additional arguments that where given to markPendingUpdatesprotected abstract String getKeyColumn()
public boolean isEmbedded()
ElementCollection that references Embeddables.getEmbeddedProperties() returns a list of propertiesprotected boolean isEntityReference()
true if the values of the collection are entitiespublic 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(Object, InsertStatement) will add the corresponding value to
the given statement@Generated(value="lombok") public GeneratorContext getContext()
@Generated(value="lombok") public List<SingularProperty<T,?>> getEmbeddedProperties()
@Generated(value="lombok") public List<EntityProperty<T,?>> getRequiredEmbeddedProperties()
@Generated(value="lombok") public String getMappedId()
@Generated(value="lombok") public String getTable()
@Generated(value="lombok") public String getIdColumn()
@Generated(value="lombok") public String getMappedBy()
@Generated(value="lombok") public boolean isUseTargetTable()
@Generated(value="lombok") public String getValueColumn()
@Generated(value="lombok") public Class<T> getValueClass()
@Generated(value="lombok") public EntityClass<T> getValueEntityClass()
valueClass, null if not an entity.@Generated(value="lombok") public ValueConverter<T> getValueConverter()
null if not a primitive value.Copyright © 2017 fastnate.org. All rights reserved.