Package io.ebeaninternal.server.deploy
Class BeanPropertyAssocOne<T>
- java.lang.Object
-
- io.ebeaninternal.server.deploy.BeanProperty
-
- io.ebeaninternal.server.deploy.BeanPropertyAssoc<T>
-
- io.ebeaninternal.server.deploy.BeanPropertyAssocOne<T>
-
- All Implemented Interfaces:
ExpressionPath
,Property
,ElPropertyDeploy
,ElPropertyValue
,STreeProperty
,STreePropertyAssoc
,STreePropertyAssocOne
,ScalarDataReader<Object>
- Direct Known Subclasses:
BeanPropertyIdClass
public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STreePropertyAssocOne
Property mapped to a joined bean.
-
-
Field Summary
-
Fields inherited from interface io.ebeaninternal.server.el.ElPropertyDeploy
ROOT_ELPREFIX
-
-
Constructor Summary
Constructors Constructor Description BeanPropertyAssocOne(BeanDescriptorMap owner, BeanDescriptor<?> descriptor, DeployBeanPropertyAssocOne<T> deploy)
Create the property.BeanPropertyAssocOne(BeanDescriptorMap owner, DeployBeanPropertyAssocOne<T> deploy)
Create based on deploy information of an EmbeddedId.BeanPropertyAssocOne(BeanPropertyAssocOne source, io.ebeaninternal.server.deploy.BeanPropertyOverride override)
Copy constructor for ManyToOne inside Embeddable.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTenant(SpiQuery<?> query, Object tenantId)
Add the tenantId predicate to the query.void
appendFrom(DbSqlContext ctx, SqlJoinType joinType)
Add any extra joins required to support this property.void
appendSelect(DbSqlContext ctx, boolean subQuery)
Append to the select clause.ElPropertyValue
buildElPropertyValue(String propName, String remainder, ElPropertyChainBuilder chain, boolean propertyDeploy)
void
buildRawSqlSelectChain(String prefix, List<String> selectChain)
For RawSql build the select chain.Object
createEmbeddedId()
Create a bean of the target type to be used as an embeddedId value.SqlUpdate
deleteByParentId(Object parentId, List<Object> parentIdist)
void
diff(String prefix, Map<String,ValuePair> map, EntityBean newBean, EntityBean oldBean)
Populate diff map comparing the property values between the beans.List<Object>
findIdsByParentId(Object parentId, List<Object> parentIds, Transaction t)
String
format(Object value)
Return the value in String format (for bean cache key).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.Object
getCacheDataValue(EntityBean bean)
Return the value for this property which we hold in the L2 cache entry.String
getElPlaceholder(boolean encrypted)
Return the place holder in the form of ${elPrefix}dbColumn.ScalarDataReader<?>
getIdReader()
Return the scalar type of the associated id property.ImportedId
getImportedId()
BeanProperty[]
getProperties()
Return meta data for the deployment of the embedded bean specific to this property.Class<?>
getTargetType()
Same as getPropertyType().EntityBean
getValueAsEntityBean(EntityBean owner)
Return the property value as an entity bean.boolean
hasCircularImportedId(BeanDescriptor<?> sourceDesc)
boolean
hasForeignKey()
Returns true, if this relation has a foreign key.void
initialise(io.ebeaninternal.server.deploy.BeanDescriptorInitContext initContext)
Initialise post construction.boolean
isAssocId()
Return true if this is an ManyToOne or OneToOne associated bean property.boolean
isAssocProperty()
Return true if any path of this path contains a Associated One or Many.boolean
isOneToOne()
Return true if this a OneToOne property.boolean
isOneToOneExported()
Return true if this is the exported side of a OneToOne.boolean
isOrphanRemoval()
boolean
isReference(Object detailBean)
void
jsonRead(SpiJsonReader readJson, EntityBean bean)
void
jsonWrite(SpiJsonWriter writeJson, EntityBean bean)
JSON write the bean property.void
jsonWriteForInsert(SpiJsonWriter writeJson, EntityBean bean)
JSON write property (non-recursive to other beans).void
jsonWriteValue(SpiJsonWriter writeJson, Object value)
JSON write property value (non-recursive to other beans).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).Object
pathGetNested(Object bean)
Return the value ensuring objects prior to the top scalar property are automatically populated.Object
read(DbReadContext ctx)
Object
read(DataReader reader)
Read and return the appropriate value from the dataReader.Object
readSet(DbReadContext ctx, EntityBean bean)
Object
readSet(DataReader reader, EntityBean bean)
void
registerColumn(BeanDescriptor<?> desc, String prefix)
void
setCacheDataValue(EntityBean bean, Object cacheData, PersistenceContext context)
Read the value for this property from L2 cache entry and set it to the bean.void
setParentBeanToChild(EntityBean parent, EntityBean child)
Set the parent bean to the child bean if it has not already been set.void
setTenantValue(EntityBean entityBean, Object tenantId)
Set the tenantId onto the bean.void
setValue(EntityBean bean, Object value)
Set the value of the property without interception or PropertyChangeSupport.void
setValueIntercept(EntityBean bean, Object value)
Set the value of the property.-
Methods inherited from class io.ebeaninternal.server.deploy.BeanPropertyAssoc
addJoin, addJoin, docStoreInclude, docStoreMapping, getBeanTable, getCascadeInfo, getExtraWhere, getFetchPreference, getForeignKey, getIdBinder, getMappedBy, getTableJoin, getTargetDescriptor, getTargetIdProperty, hasForeignKeyConstraint, hasForeignKeyIndex, hasId, isInsertable, isSaveRecurseSkippable, isSaveRecurseSkippable, isScalar, isTargetSoftDelete, isUpdateable, newQuery, target
-
Methods inherited from class io.ebeaninternal.server.deploy.BeanProperty
bind, containsFormulaWithJoin, containsMany, containsManySince, convert, getAssocIsEmpty, getBeanDescriptor, getBeanProperty, getDbBind, getDbCheckConstraintValues, getDbColumn, getDbColumnDefault, getDbComment, getDbEncryptedType, getDbLength, getDbMigrationInfos, getDbType, getDecryptProperty, getDeployOrder, getElName, getElPrefix, getEncryptKey, getEncryptKeyAsString, getFullBeanName, getGeneratedProperty, getJdbcType, getName, getProperty, getPropertyIndex, getPropertyType, getScalarType, getSecondaryTableJoinPrefix, getStringParser, getVal, getValue, getValueIntercept, isAggregation, isAssignableFrom, isAssocMany, isCacheDataInclude, isDateTimeCapable, isDbEncrypted, isDbInsertable, isDbUpdatable, isDDLColumn, isDDLNotNull, isDiscriminator, isDraft, isDraftDirty, isDraftOnly, isEmbedded, isExcludedFromHistory, isFetchEager, isFormula, isGenerated, isId, isImportedPrimaryKey, isJsonSerialize, isLoadProperty, isLob, isLobType, isLocal, isLocalEncrypted, isMany, isMutableScalarType, isNaturalKey, isNullable, isSecondaryTable, isSoftDelete, isTenantId, isTransient, isUnique, isUnmappedJson, isVersion, localEncrypt, merge, parse, parseDateTime, pathGet, pathSet, publish, readData, renderDbType, setDeployOrder, setValueChanged, toString, writeData
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.ebeaninternal.server.query.STreeProperty
getElPrefix, getEncryptKeyAsString, getFullBeanName, getName, getScalarType, isAggregation, isAggregationManyToOne, isEmbedded, isFormula, isId
-
Methods inherited from interface io.ebeaninternal.server.query.STreePropertyAssoc
addJoin, addJoin, getExtraWhere, getIdBinder, target
-
-
-
-
Constructor Detail
-
BeanPropertyAssocOne
public BeanPropertyAssocOne(BeanDescriptorMap owner, DeployBeanPropertyAssocOne<T> deploy)
Create based on deploy information of an EmbeddedId.
-
BeanPropertyAssocOne
public BeanPropertyAssocOne(BeanDescriptorMap owner, BeanDescriptor<?> descriptor, DeployBeanPropertyAssocOne<T> deploy)
Create the property.
-
BeanPropertyAssocOne
public BeanPropertyAssocOne(BeanPropertyAssocOne source, io.ebeaninternal.server.deploy.BeanPropertyOverride override)
Copy constructor for ManyToOne inside Embeddable.
-
-
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>
-
getValueAsEntityBean
public EntityBean getValueAsEntityBean(EntityBean owner)
Return the property value as an entity bean.- Specified by:
getValueAsEntityBean
in interfaceSTreePropertyAssocOne
-
buildElPropertyValue
public ElPropertyValue buildElPropertyValue(String propName, String remainder, ElPropertyChainBuilder chain, boolean propertyDeploy)
- Overrides:
buildElPropertyValue
in classBeanProperty
-
getElPlaceholder
public String getElPlaceholder(boolean encrypted)
Description copied from interface:ElPropertyDeploy
Return the place holder in the form of ${elPrefix}dbColumn.The ${elPrefix} is replaced by the appropriate table alias.
- Specified by:
getElPlaceholder
in interfaceElPropertyDeploy
- Overrides:
getElPlaceholder
in classBeanProperty
-
deleteByParentId
public SqlUpdate deleteByParentId(Object parentId, List<Object> parentIdist)
-
findIdsByParentId
public List<Object> findIdsByParentId(Object parentId, List<Object> parentIds, Transaction t)
-
registerColumn
public void registerColumn(BeanDescriptor<?> desc, String prefix)
- Overrides:
registerColumn
in classBeanProperty
-
getProperties
public BeanProperty[] getProperties()
Return meta data for the deployment of the embedded bean specific to this property.
-
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
-
hasForeignKey
public boolean hasForeignKey()
Description copied from interface:STreePropertyAssocOne
Returns true, if this relation has a foreign key.- Specified by:
hasForeignKey
in interfaceSTreePropertyAssocOne
-
isOneToOne
public boolean isOneToOne()
Return true if this a OneToOne property. Otherwise assumed ManyToOne.
-
isOneToOneExported
public boolean isOneToOneExported()
Return true if this is the exported side of a OneToOne.
-
isOrphanRemoval
public boolean isOrphanRemoval()
-
diff
public void diff(String prefix, Map<String,ValuePair> map, EntityBean newBean, EntityBean oldBean)
Description copied from class:BeanProperty
Populate diff map comparing the property values between the beans.- Overrides:
diff
in classBeanProperty
-
getTargetType
public Class<?> getTargetType()
Same as getPropertyType(). Return the type of the bean this property represents.- Overrides:
getTargetType
in classBeanPropertyAssoc<T>
-
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
-
format
public String format(Object value)
Description copied from class:BeanProperty
Return the value in String format (for bean cache key).- Overrides:
format
in classBeanProperty
-
setCacheDataValue
public void setCacheDataValue(EntityBean bean, Object cacheData, PersistenceContext context)
Description copied from class:BeanProperty
Read the value for this property from L2 cache entry and set it to the bean.This uses parse() as per the comment in getCacheDataValue().
- Overrides:
setCacheDataValue
in classBeanProperty
-
getIdReader
public ScalarDataReader<?> getIdReader()
Description copied from interface:STreePropertyAssocOne
Return the scalar type of the associated id property.- Specified by:
getIdReader
in interfaceSTreePropertyAssocOne
-
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
-
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
- Specified by:
isAssocId
in interfaceSTreePropertyAssocOne
- 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
-
createEmbeddedId
public Object createEmbeddedId()
Create a bean of the target type to be used as an embeddedId value.
-
pathGetNested
public Object pathGetNested(Object bean)
Description copied from interface:ElPropertyValue
Return the value ensuring objects prior to the top scalar property are automatically populated.- Specified by:
pathGetNested
in interfaceElPropertyValue
- Overrides:
pathGetNested
in classBeanProperty
-
getImportedId
public ImportedId getImportedId()
-
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
-
appendFrom
public void appendFrom(DbSqlContext ctx, SqlJoinType joinType)
Description copied from class:BeanProperty
Add any extra joins required to support this property. Generally a no operation except for a OneToOne exported.- Specified by:
appendFrom
in interfaceSTreeProperty
- Overrides:
appendFrom
in classBeanProperty
-
readSet
public Object readSet(DataReader reader, EntityBean bean) throws SQLException
- Overrides:
readSet
in classBeanProperty
- Throws:
SQLException
-
read
public Object read(DataReader reader) throws SQLException
Description copied from interface:ScalarDataReader
Read and return the appropriate value from the dataReader.- Specified by:
read
in interfaceScalarDataReader<T>
- Overrides:
read
in classBeanProperty
- Throws:
SQLException
-
readSet
public Object readSet(DbReadContext ctx, EntityBean bean) throws SQLException
- Overrides:
readSet
in classBeanProperty
- Throws:
SQLException
-
read
public Object read(DbReadContext ctx) throws SQLException
- Overrides:
read
in classBeanProperty
- Throws:
SQLException
-
addTenant
public void addTenant(SpiQuery<?> query, Object tenantId)
Description copied from class:BeanProperty
Add the tenantId predicate to the query.- Overrides:
addTenant
in classBeanProperty
-
setTenantValue
public void setTenantValue(EntityBean entityBean, Object tenantId)
Description copied from class:BeanProperty
Set the tenantId onto the bean.- Overrides:
setTenantValue
in classBeanProperty
-
setValue
public void setValue(EntityBean bean, Object value)
Description copied from class:BeanProperty
Set the value of the property without interception or PropertyChangeSupport.- Specified by:
setValue
in interfaceSTreePropertyAssoc
- Overrides:
setValue
in classBeanProperty
-
setValueIntercept
public void setValueIntercept(EntityBean bean, Object value)
Description copied from class:BeanProperty
Set the value of the property.- Overrides:
setValueIntercept
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
-
jsonWriteForInsert
public void jsonWriteForInsert(SpiJsonWriter writeJson, EntityBean bean) throws IOException
JSON write property (non-recursive to other beans).- Overrides:
jsonWriteForInsert
in classBeanProperty
- Throws:
IOException
-
jsonWriteValue
public void jsonWriteValue(SpiJsonWriter writeJson, Object value) throws IOException
JSON write property value (non-recursive to other beans).- Overrides:
jsonWriteValue
in classBeanProperty
- Throws:
IOException
-
jsonWrite
public void jsonWrite(SpiJsonWriter writeJson, 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 bean) throws IOException
- Overrides:
jsonRead
in classBeanProperty
- Throws:
IOException
-
isReference
public boolean isReference(Object detailBean)
-
setParentBeanToChild
public void setParentBeanToChild(EntityBean parent, EntityBean child)
Set the parent bean to the child bean if it has not already been set.
-
hasCircularImportedId
public boolean hasCircularImportedId(BeanDescriptor<?> sourceDesc)
-
-