Package io.ebeaninternal.server.deploy
Class BeanPropertyAssocMany<T>
- java.lang.Object
-
- io.ebeaninternal.server.deploy.BeanProperty
-
- io.ebeaninternal.server.deploy.BeanPropertyAssoc<T>
-
- io.ebeaninternal.server.deploy.BeanPropertyAssocMany<T>
-
- All Implemented Interfaces:
ExpressionPath
,Property
,PropertyAssocMany
,ElPropertyDeploy
,ElPropertyValue
,STreeProperty
,STreePropertyAssoc
,STreePropertyAssocMany
,ScalarDataReader<Object>
- Direct Known Subclasses:
BeanPropertySimpleCollection
public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements STreePropertyAssocMany, PropertyAssocMany
Property mapped to a List Set or Map.
-
-
Field Summary
-
Fields inherited from interface io.ebeaninternal.server.el.ElPropertyDeploy
ROOT_ELPREFIX
-
-
Constructor Summary
Constructors Constructor Description BeanPropertyAssocMany(BeanDescriptor<?> descriptor, DeployBeanPropertyAssocMany<T> deploy)
Create this property.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(BeanCollection<?> collection, EntityBean bean)
void
addBeanToCollectionWithCreate(EntityBean parentBean, EntityBean detailBean, boolean withCheck)
Add the bean to the appropriate collection on the parent bean.void
addSelectExported(DbSqlContext ctx, String tableAlias)
Append exported columns to the select.void
addWhereParentIdIn(SpiQuery<?> query, List<Object> parentIds, boolean useDocStore)
void
appendSelect(DbSqlContext ctx, boolean subQuery)
Append to the select clause.void
bindElementValue(SqlUpdate insert, Object value)
Bind all the property values to the SqlUpdate.ElPropertyValue
buildElPropertyValue(String propName, String remainder, ElPropertyChainBuilder chain, boolean propertyDeploy)
IntersectionRow
buildManyDeleteChildren(EntityBean parentBean, List<Object> excludeDetailIds)
IntersectionRow
buildManyToManyDeleteChildren(EntityBean parentBean, boolean publish)
IntersectionRow
buildManyToManyMapBean(EntityBean parent, EntityBean other, boolean publish)
void
buildRawSqlSelectChain(String prefix, List<String> selectChain)
For RawSql build the select chain.boolean
containsMany()
Returns true.BeanCollection<T>
createEmpty(EntityBean parentBean)
BeanCollection<?>
createReference(EntityBean parentBean)
BeanCollection<?>
createReference(EntityBean localBean, boolean forceNewReference)
Return a reference collection forcing a new reference on REFRESH query.BeanCollection<?>
createReferenceIfNull(EntityBean parentBean)
Return a reference collection.SpiSqlUpdate
deleteByParentId(Object parentId, List<Object> parentIdist)
List<Object>
findIdsByParentId(Object parentId, List<Object> parentIdList, Transaction t, List<Object> excludeDetailIds, boolean hard)
Find the Id's of detail beans given a parent Id or list of parent Id's.String
getAssocIdExpression(String prefix, String operator)
Return the Id expression to add to where clause etc.String
getAssocIdInExpr(String prefix)
Return the logical id in expression taking into account embedded id's.String
getAssocIdInValueExpr(boolean not, int size)
Return the logical id value expression taking into account embedded id's.Object[]
getAssocIdValues(EntityBean bean)
Return the Id values from the given bean.String
getAssocIsEmpty(SpiExpressionRequest request, String path)
Return the logical where clause to support "Is empty".Object
getCacheDataValue(EntityBean bean)
Return the value for this property which we hold in the L2 cache entry.String
getFetchOrderBy()
Return the order by clause used to order the fetching of the data for this list, set or map.TableJoin
getIntersectionTableJoin()
ManyToMany only, join from local table to intersection table.String
getLazyFetchOrderBy()
Return the order by for use when lazy loading the associated collection.ManyType
getManyType()
Return the many type.String
getMapKey()
Return the default mapKey when returning a Map.BeanCollection.ModifyListenMode
getModifyListenMode()
Return the mode for listening to modifications to collections for this association.Object
getParentId(EntityBean parentBean)
Collection
getRawCollection(EntityBean bean)
Return the underlying collection of beans.boolean
hasImportedId(EntityBean otherBean)
Return true if the otherBean has an Id value.boolean
hasJoinTable()
Return true if this is many to many.boolean
hasOrderColumn()
void
initialise(io.ebeaninternal.server.deploy.BeanDescriptorInitContext initContext)
Initialise post construction.SpiSqlUpdate
insertElementCollection()
void
intersectionBind(SqlUpdate sql, EntityBean parentBean, EntityBean other)
Bind the two side of a many to many to the given SqlUpdate.IntersectionTable
intersectionTable()
Return the intersection table helper.boolean
isAssocId()
Return true if this is an ManyToOne or OneToOne associated bean property.boolean
isAssocMany()
Return true if the property is a OneToMany or ManyToMany associated bean property.boolean
isAssocProperty()
Return true if any path of this path contains a Associated One or Many.boolean
isCacheDataInclude()
Exclude many properties from bean cache data.boolean
isElementCollection()
boolean
isIncludeCascadeDelete()
boolean
isIncludeCascadeSave()
boolean
isMany()
Return true if this is a OneToMany or ManyToMany property.boolean
isManyToMany()
Return true if this is many to many.boolean
isManyToManyWithHistory()
Return true if this is a ManyToMany with history.boolean
isO2mJoinTable()
Return true if this is a one to many with a join table.boolean
isOrphanRemoval()
boolean
isSkipSaveBeanCollection(EntityBean bean, boolean insertedParent)
Return true if this is considered 'empty' from a save perspective.boolean
isTargetDocStoreMapped()
boolean
isUseCache()
Only cache Many Ids if the target bean is also cached.void
jsonRead(SpiJsonReader readJson, EntityBean parentBean)
Object
jsonReadCollection(SpiJsonReader readJson, EntityBean parentBean)
Read the collection (JSON Array) containing entity beans.void
jsonWrite(SpiJsonWriter ctx, EntityBean bean)
JSON write the bean property.String
jsonWriteCollection(Object value)
Write the collection to JSON.void
jsonWriteValue(SpiJsonWriter writeJson, Object value)
Skip JSON write value for ToMany property.void
lazyLoadMany(EntityBean current)
Add the loaded current bean to its associated parent.void
load(SqlBeanLoad sqlBeanLoad)
Load into the bean (from the DataReader/ResultSet).void
loadIgnore(DbReadContext ctx)
Ignore the property (moving the column index position without reading).void
merge(EntityBean bean, EntityBean existing)
Copy collection value if existing is empty.Object
read(DbReadContext ctx)
Object
readSet(DbReadContext ctx, EntityBean bean)
void
registerColumn(BeanDescriptor<?> desc, String prefix)
void
resetMany(EntityBean bean)
Reset the many properties to be empty and ready for reloading.void
setCacheDataValue(EntityBean bean, Object cacheData, PersistenceContext context)
A Many (element collection) property in bean cache to held as JSON.void
setEbeanServer(SpiEbeanServer server)
Set the lazy load server to help create reference collections (that lazy load on demand).void
setJoinValuesToChild(EntityBean parent, EntityBean child, Object mapKeyValue)
Set the join properties from the parent bean to the child bean.-
Methods inherited from class io.ebeaninternal.server.deploy.BeanPropertyAssoc
addJoin, addJoin, docStoreInclude, docStoreMapping, getBeanTable, getCascadeInfo, getExtraWhere, getFetchPreference, getForeignKey, getIdBinder, getMappedBy, getTableJoin, getTargetDescriptor, getTargetIdProperty, getTargetType, hasForeignKeyConstraint, hasForeignKeyIndex, hasId, isInsertable, isSaveRecurseSkippable, isSaveRecurseSkippable, isScalar, isTargetSoftDelete, isUpdateable, newQuery, target
-
Methods inherited from class io.ebeaninternal.server.deploy.BeanProperty
addTenant, appendFrom, bind, containsFormulaWithJoin, containsManySince, convert, diff, format, getBeanDescriptor, getBeanProperty, getDbBind, getDbCheckConstraintValues, getDbColumn, getDbColumnDefault, getDbComment, getDbEncryptedType, getDbLength, getDbMigrationInfos, getDbType, getDecryptProperty, getDeployOrder, getElName, getElPlaceholder, getElPrefix, getEncryptKey, getEncryptKeyAsString, getFullBeanName, getGeneratedProperty, getJdbcType, getName, getProperty, getPropertyIndex, getPropertyType, getScalarType, getSecondaryTableJoinPrefix, getStringParser, getVal, getValue, getValueIntercept, isAggregation, isAssignableFrom, isDateTimeCapable, isDbEncrypted, isDbInsertable, isDbUpdatable, isDDLColumn, isDDLNotNull, isDiscriminator, isDraft, isDraftDirty, isDraftOnly, isEmbedded, isExcludedFromHistory, isFetchEager, isFormula, isGenerated, isId, isImportedPrimaryKey, isJsonSerialize, isLoadProperty, isLob, isLobType, isLocal, isLocalEncrypted, isMutableScalarType, isNaturalKey, isNullable, isSecondaryTable, isSoftDelete, isTenantId, isTransient, isUnique, isUnmappedJson, isVersion, jsonWriteForInsert, localEncrypt, parse, parseDateTime, pathGet, pathGetNested, pathSet, publish, read, readData, readSet, renderDbType, setDeployOrder, setTenantValue, setValue, setValueChanged, setValueIntercept, toString, writeData
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.ebean.plugin.Property
getName, getPropertyType, getVal
-
Methods inherited from interface io.ebeaninternal.server.type.ScalarDataReader
read
-
Methods inherited from interface io.ebeaninternal.server.query.STreeProperty
appendFrom, getElPrefix, getEncryptKeyAsString, getFullBeanName, getName, getScalarType, isAggregation, isAggregationManyToOne, isEmbedded, isFormula, isId
-
Methods inherited from interface io.ebeaninternal.server.query.STreePropertyAssoc
addJoin, addJoin, getExtraWhere, getIdBinder, setValue, target
-
Methods inherited from interface io.ebeaninternal.server.query.STreePropertyAssocMany
isExcludedFromHistory
-
-
-
-
Constructor Detail
-
BeanPropertyAssocMany
public BeanPropertyAssocMany(BeanDescriptor<?> descriptor, DeployBeanPropertyAssocMany<T> deploy)
Create this property.
-
-
Method Detail
-
initialise
public void initialise(io.ebeaninternal.server.deploy.BeanDescriptorInitContext initContext)
Description copied from class:BeanPropertyAssoc
Initialise post construction.- Overrides:
initialise
in classBeanPropertyAssoc<T>
-
isManyToManyWithHistory
public boolean isManyToManyWithHistory()
Description copied from interface:STreePropertyAssocMany
Return true if this is a ManyToMany with history.- Specified by:
isManyToManyWithHistory
in interfaceSTreePropertyAssocMany
-
registerColumn
public void registerColumn(BeanDescriptor<?> desc, String prefix)
- Overrides:
registerColumn
in classBeanProperty
-
getRawCollection
public Collection getRawCollection(EntityBean bean)
Return the underlying collection of beans.
-
merge
public void merge(EntityBean bean, EntityBean existing)
Copy collection value if existing is empty.- Overrides:
merge
in classBeanProperty
-
addBeanToCollectionWithCreate
public void addBeanToCollectionWithCreate(EntityBean parentBean, EntityBean detailBean, boolean withCheck)
Add the bean to the appropriate collection on the parent bean.- Specified by:
addBeanToCollectionWithCreate
in interfaceSTreePropertyAssocMany
-
isSkipSaveBeanCollection
public boolean isSkipSaveBeanCollection(EntityBean bean, boolean insertedParent)
Return true if this is considered 'empty' from a save perspective.
-
resetMany
public void resetMany(EntityBean bean)
Reset the many properties to be empty and ready for reloading.Used in bean refresh.
-
buildElPropertyValue
public ElPropertyValue buildElPropertyValue(String propName, String remainder, ElPropertyChainBuilder chain, boolean propertyDeploy)
- Overrides:
buildElPropertyValue
in classBeanProperty
-
buildRawSqlSelectChain
public void buildRawSqlSelectChain(String prefix, List<String> selectChain)
Description copied from interface:STreeProperty
For RawSql build the select chain.- Specified by:
buildRawSqlSelectChain
in interfaceSTreeProperty
- Overrides:
buildRawSqlSelectChain
in classBeanProperty
-
deleteByParentId
public SpiSqlUpdate deleteByParentId(Object parentId, List<Object> parentIdist)
-
findIdsByParentId
public List<Object> findIdsByParentId(Object parentId, List<Object> parentIdList, Transaction t, List<Object> excludeDetailIds, boolean hard)
Find the Id's of detail beans given a parent Id or list of parent Id's.
-
isCacheDataInclude
public boolean isCacheDataInclude()
Exclude many properties from bean cache data.- Overrides:
isCacheDataInclude
in classBeanProperty
-
lazyLoadMany
public void lazyLoadMany(EntityBean current)
Add the loaded current bean to its associated parent.Helper method used by Elastic integration when loading with a persistence context.
- Specified by:
lazyLoadMany
in interfacePropertyAssocMany
-
addWhereParentIdIn
public void addWhereParentIdIn(SpiQuery<?> query, List<Object> parentIds, boolean useDocStore)
-
setEbeanServer
public void setEbeanServer(SpiEbeanServer server)
Set the lazy load server to help create reference collections (that lazy load on demand).
-
intersectionTable
public IntersectionTable intersectionTable()
Return the intersection table helper.
-
getModifyListenMode
public BeanCollection.ModifyListenMode getModifyListenMode()
Return the mode for listening to modifications to collections for this association.
-
appendSelect
public void appendSelect(DbSqlContext ctx, boolean subQuery)
Description copied from interface:STreeProperty
Append to the select clause.- Specified by:
appendSelect
in interfaceSTreeProperty
- Overrides:
appendSelect
in classBeanProperty
-
loadIgnore
public void loadIgnore(DbReadContext ctx)
Description copied from interface:STreeProperty
Ignore the property (moving the column index position without reading).- Specified by:
loadIgnore
in interfaceSTreeProperty
- Overrides:
loadIgnore
in classBeanProperty
-
load
public void load(SqlBeanLoad sqlBeanLoad)
Description copied from interface:STreeProperty
Load into the bean (from the DataReader/ResultSet).- Specified by:
load
in interfaceSTreeProperty
- Overrides:
load
in classBeanProperty
-
readSet
public Object readSet(DbReadContext ctx, EntityBean bean)
- Overrides:
readSet
in classBeanProperty
-
read
public Object read(DbReadContext ctx)
- Overrides:
read
in classBeanProperty
-
add
public void add(BeanCollection<?> collection, EntityBean bean)
-
getAssocIsEmpty
public String getAssocIsEmpty(SpiExpressionRequest request, String path)
Description copied from interface:ElPropertyValue
Return the logical where clause to support "Is empty".- Specified by:
getAssocIsEmpty
in interfaceElPropertyValue
- Overrides:
getAssocIsEmpty
in classBeanProperty
-
getAssocIdValues
public Object[] getAssocIdValues(EntityBean bean)
Return the Id values from the given bean.- Specified by:
getAssocIdValues
in interfaceExpressionPath
- Overrides:
getAssocIdValues
in classBeanProperty
-
getAssocIdExpression
public String getAssocIdExpression(String prefix, String operator)
Return the Id expression to add to where clause etc.- Specified by:
getAssocIdExpression
in interfaceExpressionPath
- Overrides:
getAssocIdExpression
in classBeanProperty
-
getAssocIdInValueExpr
public String getAssocIdInValueExpr(boolean not, int size)
Return the logical id value expression taking into account embedded id's.- Specified by:
getAssocIdInValueExpr
in interfaceElPropertyValue
- Overrides:
getAssocIdInValueExpr
in classBeanProperty
-
getAssocIdInExpr
public String getAssocIdInExpr(String prefix)
Return the logical id in expression taking into account embedded id's.- Specified by:
getAssocIdInExpr
in interfaceElPropertyValue
- Overrides:
getAssocIdInExpr
in classBeanProperty
-
isMany
public boolean isMany()
Description copied from interface:Property
Return true if this is a OneToMany or ManyToMany property.- Specified by:
isMany
in interfaceProperty
- Overrides:
isMany
in classBeanProperty
-
hasOrderColumn
public boolean hasOrderColumn()
-
isOrphanRemoval
public boolean isOrphanRemoval()
-
isAssocMany
public boolean isAssocMany()
Description copied from interface:ElPropertyValue
Return true if the property is a OneToMany or ManyToMany associated bean property.- Specified by:
isAssocMany
in interfaceElPropertyValue
- Overrides:
isAssocMany
in classBeanProperty
-
isAssocId
public boolean isAssocId()
Description copied from interface:ElPropertyValue
Return true if this is an ManyToOne or OneToOne associated bean property.- Specified by:
isAssocId
in interfaceElPropertyValue
- Specified by:
isAssocId
in interfaceExpressionPath
- Overrides:
isAssocId
in classBeanProperty
-
isAssocProperty
public boolean isAssocProperty()
Description copied from interface:ElPropertyValue
Return true if any path of this path contains a Associated One or Many.- Specified by:
isAssocProperty
in interfaceElPropertyValue
- Overrides:
isAssocProperty
in classBeanProperty
-
containsMany
public boolean containsMany()
Returns true.- Specified by:
containsMany
in interfaceElPropertyDeploy
- Specified by:
containsMany
in interfaceExpressionPath
- Overrides:
containsMany
in classBeanProperty
-
getManyType
public ManyType getManyType()
Return the many type.
-
hasJoinTable
public boolean hasJoinTable()
Return true if this is many to many.- Specified by:
hasJoinTable
in interfaceSTreePropertyAssocMany
-
isO2mJoinTable
public boolean isO2mJoinTable()
Return true if this is a one to many with a join table.
-
isManyToMany
public boolean isManyToMany()
Return true if this is many to many.
-
isElementCollection
public boolean isElementCollection()
-
getIntersectionTableJoin
public TableJoin getIntersectionTableJoin()
ManyToMany only, join from local table to intersection table.- Specified by:
getIntersectionTableJoin
in interfaceSTreePropertyAssocMany
-
setJoinValuesToChild
public void setJoinValuesToChild(EntityBean parent, EntityBean child, Object mapKeyValue)
Set the join properties from the parent bean to the child bean. This is only valid for OneToMany and NOT valid for ManyToMany.
-
getFetchOrderBy
public String getFetchOrderBy()
Return the order by clause used to order the fetching of the data for this list, set or map.
-
getLazyFetchOrderBy
public String getLazyFetchOrderBy()
Return the order by for use when lazy loading the associated collection.
-
createReference
public BeanCollection<?> createReference(EntityBean localBean, boolean forceNewReference)
Description copied from interface:STreePropertyAssocMany
Return a reference collection forcing a new reference on REFRESH query.- Specified by:
createReference
in interfaceSTreePropertyAssocMany
-
createReferenceIfNull
public BeanCollection<?> createReferenceIfNull(EntityBean parentBean)
Description copied from interface:STreePropertyAssocMany
Return a reference collection.- Specified by:
createReferenceIfNull
in interfaceSTreePropertyAssocMany
-
createReference
public BeanCollection<?> createReference(EntityBean parentBean)
-
createEmpty
public BeanCollection<T> createEmpty(EntityBean parentBean)
-
getParentId
public Object getParentId(EntityBean parentBean)
-
addSelectExported
public void addSelectExported(DbSqlContext ctx, String tableAlias)
Description copied from interface:STreePropertyAssocMany
Append exported columns to the select.- Specified by:
addSelectExported
in interfaceSTreePropertyAssocMany
-
buildManyDeleteChildren
public IntersectionRow buildManyDeleteChildren(EntityBean parentBean, List<Object> excludeDetailIds)
-
buildManyToManyDeleteChildren
public IntersectionRow buildManyToManyDeleteChildren(EntityBean parentBean, boolean publish)
-
buildManyToManyMapBean
public IntersectionRow buildManyToManyMapBean(EntityBean parent, EntityBean other, boolean publish)
-
intersectionBind
public void intersectionBind(SqlUpdate sql, EntityBean parentBean, EntityBean other)
Bind the two side of a many to many to the given SqlUpdate.
-
hasImportedId
public boolean hasImportedId(EntityBean otherBean)
Return true if the otherBean has an Id value.
-
jsonWriteValue
public void jsonWriteValue(SpiJsonWriter writeJson, Object value)
Skip JSON write value for ToMany property.- Overrides:
jsonWriteValue
in classBeanProperty
-
jsonWrite
public void jsonWrite(SpiJsonWriter ctx, EntityBean bean) throws IOException
Description copied from class:BeanProperty
JSON write the bean property.- Overrides:
jsonWrite
in classBeanProperty
- Throws:
IOException
-
jsonRead
public void jsonRead(SpiJsonReader readJson, EntityBean parentBean) throws IOException
- Overrides:
jsonRead
in classBeanProperty
- Throws:
IOException
-
isIncludeCascadeSave
public boolean isIncludeCascadeSave()
-
isIncludeCascadeDelete
public boolean isIncludeCascadeDelete()
-
insertElementCollection
public SpiSqlUpdate insertElementCollection()
-
isTargetDocStoreMapped
public boolean isTargetDocStoreMapped()
-
isUseCache
public boolean isUseCache()
Only cache Many Ids if the target bean is also cached.
-
setCacheDataValue
public void setCacheDataValue(EntityBean bean, Object cacheData, PersistenceContext context)
A Many (element collection) property in bean cache to held as JSON.- Overrides:
setCacheDataValue
in classBeanProperty
-
getCacheDataValue
public Object getCacheDataValue(EntityBean bean)
Description copied from class:BeanProperty
Return the value for this property which we hold in the L2 cache entry.This uses format() where possible to store the value as a string and this is done to make any resulting Java object serialisation content smaller as strings get special treatment.
- Overrides:
getCacheDataValue
in classBeanProperty
-
jsonWriteCollection
public String jsonWriteCollection(Object value) throws IOException
Write the collection to JSON.- Throws:
IOException
-
jsonReadCollection
public Object jsonReadCollection(SpiJsonReader readJson, EntityBean parentBean) throws IOException
Read the collection (JSON Array) containing entity beans.- Throws:
IOException
-
bindElementValue
public void bindElementValue(SqlUpdate insert, Object value)
Bind all the property values to the SqlUpdate.
-
-