Class BeanProperty

java.lang.Object
io.ebeaninternal.server.deploy.BeanProperty
All Implemented Interfaces:
ScalarDataReader<Object>, ExpressionPath, Property, ElPropertyDeploy, ElPropertyValue, STreeProperty
Direct Known Subclasses:
BeanPropertyAssoc, BeanPropertyJsonBasic, BeanPropertyOrderColumn

public class BeanProperty extends Object implements ElPropertyValue, Property, STreeProperty
Description of a property of a bean. Includes its deployment information such as database column mapping information.
  • Field Details

    • id

      protected final boolean id
      Flag to mark this is the id property.
  • Constructor Details

    • BeanProperty

      public BeanProperty(DeployBeanProperty deploy)
    • BeanProperty

      public BeanProperty(BeanDescriptor<?> descriptor, DeployBeanProperty deploy)
    • BeanProperty

      protected BeanProperty(BeanProperty source, io.ebeaninternal.server.deploy.BeanPropertyOverride override)
      Create a Matching BeanProperty with some attributes overridden for Embedded beans.
  • Method Details

    • override

      public BeanProperty override(io.ebeaninternal.server.deploy.BeanPropertyOverride override)
    • initialise

      public void initialise(io.ebeaninternal.server.deploy.BeanDescriptorInitContext initContext)
      Initialise the property before returning to client code. Used to initialise variables that can't be done in construction due to recursive issues.
    • deployOrder

      public int deployOrder()
      Return the order this property appears in the bean.
    • setDeployOrder

      public void setDeployOrder(int deployOrder)
      Set the order this property appears in the bean.
    • buildElPropertyValue

      public ElPropertyValue buildElPropertyValue(String propName, String remainder, ElPropertyChainBuilder chain, boolean propertyDeploy)
    • descriptor

      public BeanDescriptor<?> descriptor()
      Return the BeanDescriptor that owns this property.
    • isScalar

      public boolean isScalar()
      Return true is this is a simple scalar property.
    • isDDLColumn

      public boolean isDDLColumn()
      Return true if this property should have a DB Column created in DDL.
    • isFormula

      public boolean isFormula()
      Return true if this property is based on a formula.
      Specified by:
      isFormula in interface STreeProperty
    • isDiscriminator

      public boolean isDiscriminator()
      Return true if this property maps to the inheritance discriminator column.
    • isMutableScalarType

      public boolean isMutableScalarType()
      Return true if the underlying type is mutable.
    • encryptKey

      public EncryptKey encryptKey()
      Return the encrypt key for the column matching this property.
    • encryptKeyAsString

      public String encryptKeyAsString()
      Description copied from interface: STreeProperty
      Return the encryption key as a string value (when the property is encrypted).
      Specified by:
      encryptKeyAsString in interface STreeProperty
    • decryptProperty

      public String decryptProperty(String propertyName)
    • fetchPreference

      public int fetchPreference()
      Description copied from interface: ElPropertyDeploy
      Return the fetch preference. This can be used to control which ToMany relationship is left as a 'join' and which get converted to query join.
      Specified by:
      fetchPreference in interface ElPropertyDeploy
    • appendFrom

      public void appendFrom(DbSqlContext ctx, SqlJoinType joinType, String manyWhere)
      Add any extra joins required to support this property. Generally a no operation except for a OneToOne exported.
      Specified by:
      appendFrom in interface STreeProperty
    • secondaryTableJoinPrefix

      public String secondaryTableJoinPrefix()
      Returns null unless this property is using a secondary table. In that case this returns the logical property prefix.
    • isAggregation

      public boolean isAggregation()
      Description copied from interface: ElPropertyDeploy
      Return true if this is an aggregation property.
      Specified by:
      isAggregation in interface ElPropertyDeploy
      Specified by:
      isAggregation in interface STreeProperty
    • appendSelect

      public void appendSelect(DbSqlContext ctx, boolean subQuery)
      Description copied from interface: STreeProperty
      Append to the select clause.
      Specified by:
      appendSelect in interface STreeProperty
    • isMany

      public boolean isMany()
      Specified by:
      isMany in interface Property
    • isAssignableFrom

      public boolean isAssignableFrom(Class<?> type)
    • 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 interface STreeProperty
    • load

      public void load(SqlBeanLoad sqlBeanLoad)
      Description copied from interface: STreeProperty
      Load into the bean (from the DataReader/ResultSet).
      Specified by:
      load in interface STreeProperty
    • buildRawSqlSelectChain

      public void buildRawSqlSelectChain(String prefix, List<String> selectChain)
      Description copied from interface: STreeProperty
      For RawSql build the select chain.
      Specified by:
      buildRawSqlSelectChain in interface STreeProperty
    • read

      public Object read(DataReader reader) throws SQLException
      Specified by:
      read in interface ScalarDataReader<Object>
      Throws:
      SQLException
    • readSet

      public Object readSet(DataReader reader, EntityBean bean) throws SQLException
      Throws:
      SQLException
    • read

      public Object read(DbReadContext ctx) throws SQLException
      Throws:
      SQLException
    • readSet

      public Object readSet(DbReadContext ctx, EntityBean bean) throws SQLException
      Throws:
      SQLException
    • bind

      public void bind(io.ebeaninternal.server.bind.DataBind b, Object value) throws SQLException
      Throws:
      SQLException
    • writeData

      public void writeData(DataOutput dataOutput, Object value) throws IOException
      Throws:
      IOException
    • readData

      public Object readData(DataInput dataInput) throws IOException
      Throws:
      IOException
    • beanProperty

      public BeanProperty beanProperty()
      Description copied from interface: ElPropertyDeploy
      Return the underlying bean property.
      Specified by:
      beanProperty in interface ElPropertyDeploy
    • property

      public Property property()
      Specified by:
      property in interface ExpressionPath
    • isLocal

      public boolean isLocal()
      Return true is this type is not from a super type.
    • setValueChanged

      public void setValueChanged(EntityBean bean, Object value)
      Set the changed value without invoking interception (lazy loading etc). Typically used to set generated values on update.
    • addTenant

      public void addTenant(SpiQuery<?> query, Object tenantId)
      Add the tenantId predicate to the query.
    • setTenantValue

      public void setTenantValue(EntityBean entityBean, Object tenantId)
      Set the tenantId onto the bean.
    • setValue

      public void setValue(EntityBean bean, Object value)
      Set the value of the property without interception or PropertyChangeSupport.
    • setValueIntercept

      public void setValueIntercept(EntityBean bean, Object value)
      Set the value of the property.
    • isCacheDataInclude

      public boolean isCacheDataInclude()
      Return true if this property should be included in the cache bean data.
    • getCacheDataValue

      public Object getCacheDataValue(EntityBean bean)
      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.

    • getCacheDataValueOrig

      public Object getCacheDataValueOrig(EntityBeanIntercept ebi)
      Return the bean cache value for this property using original values.
    • format

      public String format(Object value)
      Return the value in String format (for bean cache key).
    • parse

      public Object parse(String value)
      Return the value from String format into Object value.
    • createMutableInfo

      public MutableValueInfo createMutableInfo(String json)
      creates a mutableHash for the given JSON value.
    • setCacheDataValue

      public void setCacheDataValue(EntityBean bean, Object cacheData, PersistenceContext context)
      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().

    • value

      public Object value(Object bean)
      Specified by:
      value in interface Property
    • getValue

      public Object getValue(EntityBean bean)
      Return the value of the property method.
    • getValueIntercept

      public Object getValueIntercept(EntityBean bean)
    • convert

      public Object convert(Object value)
      Specified by:
      convert in interface ExpressionPath
    • pathSet

      public void pathSet(Object bean, Object value)
      Specified by:
      pathSet in interface ExpressionPath
    • pathGet

      public Object pathGet(Object bean)
      Specified by:
      pathGet in interface ExpressionPath
    • 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 interface ElPropertyValue
    • name

      public String name()
      Return the name of the property.
      Specified by:
      name in interface ElPropertyDeploy
      Specified by:
      name in interface Property
      Specified by:
      name in interface STreeProperty
    • propertyIndex

      public int propertyIndex()
      Return the position of this property in the enhanced bean.
    • elName

      public String elName()
      Description copied from interface: ElPropertyDeploy
      The ElPrefix plus name.
      Specified by:
      elName in interface ElPropertyDeploy
      Specified by:
      elName in interface ExpressionPath
    • containsFormulaWithJoin

      public boolean containsFormulaWithJoin()
      Description copied from interface: ElPropertyDeploy
      Return true if the property is a formula with a join clause.
      Specified by:
      containsFormulaWithJoin in interface ElPropertyDeploy
    • containsManySince

      public boolean containsManySince(String sinceProperty)
      Description copied from interface: ElPropertyDeploy
      Return true if there is a property is on the path after sinceProperty that is a 'many' property.
      Specified by:
      containsManySince in interface ElPropertyDeploy
    • containsMany

      public boolean containsMany()
      Description copied from interface: ElPropertyDeploy
      Return true if there is a property on the path that is a many property.
      Specified by:
      containsMany in interface ElPropertyDeploy
      Specified by:
      containsMany in interface ExpressionPath
    • assocIsEmpty

      public String assocIsEmpty(SpiExpressionRequest request, String path)
      Description copied from interface: ElPropertyValue
      Return the logical where clause to support "Is empty".
      Specified by:
      assocIsEmpty in interface ElPropertyValue
    • assocIdValues

      public Object[] assocIdValues(EntityBean bean)
      Specified by:
      assocIdValues in interface ExpressionPath
    • assocIdExpression

      public String assocIdExpression(String prefix, String operator)
      Specified by:
      assocIdExpression in interface ExpressionPath
    • assocIdInExpr

      public String assocIdInExpr(String prefix)
      Description copied from interface: ElPropertyValue
      Return the logical id in expression taking into account embedded id's.
      Specified by:
      assocIdInExpr in interface ElPropertyValue
    • assocIdInValueExpr

      public String assocIdInValueExpr(boolean not, int size)
      Description copied from interface: ElPropertyValue
      Return the logical id value expression taking into account embedded id's.
      Specified by:
      assocIdInValueExpr in interface ElPropertyValue
    • isImportedPrimaryKey

      public boolean isImportedPrimaryKey()
      If true this bean maps to the primary key.
    • 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 interface ElPropertyValue
    • 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 interface ElPropertyValue
      Specified by:
      isAssocId in interface ExpressionPath
    • 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 interface ElPropertyValue
    • elPlaceholder

      public String elPlaceholder(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:
      elPlaceholder in interface ElPropertyDeploy
    • elPrefix

      public String elPrefix()
      Description copied from interface: ElPropertyDeploy
      Return the prefix path of the property.

      This is use to determine joins required to support this property.

      Specified by:
      elPrefix in interface ElPropertyDeploy
      Specified by:
      elPrefix in interface STreeProperty
    • fullName

      public String fullName()
      Return the full name of this property.
      Specified by:
      fullName in interface STreeProperty
    • isArrayType

      public boolean isArrayType()
    • scalarType

      public ScalarType<Object> scalarType()
      Return the scalarType.
      Specified by:
      scalarType in interface STreeProperty
    • stringParser

      public StringParser stringParser()
      Specified by:
      stringParser in interface ExpressionPath
    • jdbcType

      public int jdbcType()
      Specified by:
      jdbcType in interface ExpressionPath
    • dbLength

      public int dbLength()
      Return the DB max length (varchar) or precision (decimal).
    • dbScale

      public int dbScale()
      Return the DB scale for numeric columns.
    • dbColumnDefn

      public String dbColumnDefn()
      Return a specific column DDL definition if specified (otherwise null).
    • dbCheckConstraintValues

      public Set<String> dbCheckConstraintValues()
      Return the DB constraint expression (can be null).

      For an Enum returns IN expression for the set of Enum values.

    • renderDbType

      public String renderDbType(DbPlatformType dbType, boolean strict)
      Return the DB column type definition.
    • dbColumnDefault

      public String dbColumnDefault()
      Return the DB column default to use for DDL.
    • dbMigrationInfos

      public List<DbMigrationInfo> dbMigrationInfos()
      Return the DDL-Migration Infos
    • generatedProperty

      public io.ebeaninternal.server.deploy.generatedproperty.GeneratedProperty generatedProperty()
      Return the GeneratedValue. Used to generate update timestamp etc.
    • isNaturalKey

      public boolean isNaturalKey()
      Return true if this is the natural key property.
    • isNullable

      public boolean isNullable()
      Return true if this property is mandatory.
    • isDDLNotNull

      public boolean isDDLNotNull()
      Return true if DDL Not NULL constraint should be defined for this column based on it being a version column or having a generated property.
    • isGenerated

      public boolean isGenerated()
      Return true if this is a generated or Id property.
    • isUnique

      public boolean isUnique()
      Return true if the DB column should be unique.
    • isTransient

      public boolean isTransient()
      Return true if the property is transient.
    • isLoadProperty

      public boolean isLoadProperty()
      Return true if this property is loadable from a resultSet.
    • isVersion

      public boolean isVersion()
      Return true if this is a version column used for concurrency checking.
    • dbColumn

      public String dbColumn()
      The database column name this is mapped to.
      Specified by:
      dbColumn in interface ElPropertyDeploy
    • dbComment

      public String dbComment()
      Return the comment for the associated DB column.
    • dbType

      public int dbType(boolean platformTypes)
      Return the database jdbc data type this is mapped to.
      Parameters:
      platformTypes - Set as false when we want logical platform agnostic types.
    • isFetchEager

      public boolean isFetchEager()
      Return true if by default this property is set to fetch eager. Lob's usually default to fetch lazy.
    • isLob

      public boolean isLob()
      Return true if this is mapped to a Clob Blob LongVarchar or LongVarbinary.
    • isLobForPlatform

      public boolean isLobForPlatform()
      Returns true if this isLob() or the type will effectively map to a lob.
      Specified by:
      isLobForPlatform in interface STreeProperty
    • isLobType

      public static boolean isLobType(int type)
    • dbBind

      public String dbBind()
      Return the DB bind parameter. Typically is "?" but different for encrypted bind.
    • localEncrypt

      public Object localEncrypt(Object value)
      Description copied from interface: ElPropertyValue
      Encrypt the input value return the encrypted value.
      Specified by:
      localEncrypt in interface ElPropertyValue
    • isLocalEncrypted

      public boolean isLocalEncrypted()
      Returns true if DB encrypted.
      Specified by:
      isLocalEncrypted in interface ElPropertyValue
    • isDbEncrypted

      public boolean isDbEncrypted()
      Return true if this property is stored encrypted.
      Specified by:
      isDbEncrypted in interface ElPropertyValue
    • dbEncryptedType

      public int dbEncryptedType()
    • isExcludedFromHistory

      public boolean isExcludedFromHistory()
      Return true if this property is excluded from history.
    • isUnmappedJson

      public boolean isUnmappedJson()
      Return true if this property hold unmapped JSON.
    • isTenantId

      public boolean isTenantId()
      Return true if this is the tenantId property (for multi-tenant partitioning).
    • isSoftDelete

      public boolean isSoftDelete()
      Return true if this property is the soft delete property.
    • isDbInsertable

      public boolean isDbInsertable()
      Return true if this property should be included in an Insert.
    • isDbUpdatable

      public boolean isDbUpdatable()
      Return true if this property should be included in an Update.
    • isSecondaryTable

      public boolean isSecondaryTable()
      Return true if this property is based on a secondary table (not the base table).
    • type

      public Class<?> type()
      Return the property type.
      Specified by:
      type in interface Property
    • isId

      public boolean isId()
      Return true if this is included in the unique id.
      Specified by:
      isId in interface STreeProperty
    • isEmbedded

      public boolean isEmbedded()
      Return true if this is an Embedded property. In this case it shares the table and primary key of its owner object.
      Specified by:
      isEmbedded in interface STreeProperty
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isJsonSerialize

      public boolean isJsonSerialize()
    • jsonWriteForInsert

      public void jsonWriteForInsert(SpiJsonWriter writeJson, EntityBean bean) throws IOException
      JSON write the property for 'insert only depth'.
      Throws:
      IOException
    • jsonWriteValue

      public void jsonWriteValue(SpiJsonWriter writeJson, Object value) throws IOException
      JSON write the property value.
      Throws:
      IOException
    • jsonWrite

      public void jsonWrite(SpiJsonWriter writeJson, EntityBean bean) throws IOException
      JSON write the bean property.
      Throws:
      IOException
    • jsonRead

      public void jsonRead(SpiJsonReader ctx, EntityBean bean) throws IOException
      Throws:
      IOException
    • jsonRead

      public Object jsonRead(SpiJsonReader ctx) throws IOException
      Throws:
      IOException
    • diff

      public void diff(String prefix, Map<String,ValuePair> map, EntityBean newBean, EntityBean oldBean)
      Populate diff map comparing the property values between the beans.
    • merge

      public void merge(EntityBean bean, EntityBean existing)
    • registerColumn

      public void registerColumn(BeanDescriptor<?> desc, String prefix)