Package sc.db

Class DBPropertyDescriptor

  • Direct Known Subclasses:
    IdPropertyDescriptor, MultiColPropertyDescriptor

    public class DBPropertyDescriptor
    extends java.lang.Object
    Represents the metadata used for storing a property of a DBObject. It lives in a TableDescriptor that is part of an enclosing DBTypeDescriptor. This instance is used to define the first column in the mapping. See the subclass MultiColPropertyDescriptor for when there's more than one column used to refer to a single property in the model. The DBPropertyDescriptor is built from the DBPropertySettings annotation, along with defaults inherited from DBTypeSettings.
    • Field Detail

      • RefIdPropertySuffix

        public static final java.lang.String RefIdPropertySuffix
        See Also:
        Constant Field Values
      • propertyName

        public java.lang.String propertyName
      • columnName

        public java.lang.String columnName
      • columnType

        public java.lang.String columnType
      • tableName

        public java.lang.String tableName
        Optional table name - if not set, uses either the primary table, or another table for multi-row properties
      • required

        public boolean required
      • unique

        public boolean unique
      • onDemand

        public boolean onDemand
        For relationships, should the referenced value be selected in-line, or should we wait till the properties of the referenced object are access to select them
      • dynColumn

        public boolean dynColumn
        Set to true for properties to be stored in a single JSON column - not part of the normalized schema for the type
      • indexed

        public boolean indexed
        Set to true for a property that should be indexed in the database for faster searches
      • dataSourceName

        public java.lang.String dataSourceName
        When the property is stored in a separate data source, specifies that data source name
      • selectGroup

        public java.lang.String selectGroup
        Override the default selecting behavior for the property and instead select it with a group created with this name. All properties using the same selectGroup are populated at the same time By default, a property's selectGroup is the Java style-name for the table the property is defined in
      • refTypeName

        public java.lang.String refTypeName
        For both single and multi-valued properties that refer to other DBObject's persisted, specifies the type name for this reference
      • multiRow

        public boolean multiRow
        True if this property is a multi-valued property and is stored with a separate row per value (as opposed to a serialized form like JSON stored in a column)
      • reverseProperty

        public java.lang.String reverseProperty
        For bi-directional relationships, stores the name of the reverse property. This is used to determine the nature of the relationship - one-to-many, one-to-one or many-to-many and for the default table layout for storing the items.
      • dbDefault

        public java.lang.String dbDefault
        If set, the value to use for the 'default' statement in the DDL
      • readOnly

        public boolean readOnly
        True for properties that are read from the database, but not updated. This is set in particular for reverse properties in a relationship - only one side needs to update based on the change.
      • typeIdProperty

        public boolean typeIdProperty
        Set to true for the typeId property
      • ownerTypeName

        public java.lang.String ownerTypeName
        For properties defined in a subclass, specifies the type name of the class where this property is defined. We can't just use dbTypeDesc to define this because we need to define the Table with this property before we define the subtype itself.
      • dbTypeDesc

        public DBTypeDescriptor dbTypeDesc
        The type this property descriptor is defined in. When a subclass shares a table with a base class, this points to the subclass the property is defined in
      • tableDesc

        public TableDescriptor tableDesc
        Reference to the table for this property
      • refDBTypeDesc

        public DBTypeDescriptor refDBTypeDesc
        When this property references one or more other properties, this is the type descriptor for that reference
      • propertyType

        public java.lang.Object propertyType
        Especially for compile mode when property mapper is not available - the type of this property
      • orderBy

        public java.util.List<java.lang.String> orderBy
        List of String path names (a.b) prefixed with a '-' if it's a reverse direction sort
      • orderByDirs

        public java.util.List<java.lang.Boolean> orderByDirs
      • reversePropDesc

        public DBPropertyDescriptor reversePropDesc
        If this property participates in a bi-directional relationship, points to the back-pointing property - i.e. refDBTypeDesc == reversePropDesc.dbTypeDesc && reversePropDesc.reversePropDesc.refDBTypeDesc == dbTypeDesc
    • Constructor Detail

      • DBPropertyDescriptor

        public DBPropertyDescriptor​(java.lang.String propertyName,
                                    java.lang.String columnName,
                                    java.lang.String columnType,
                                    java.lang.String tableName,
                                    boolean required,
                                    boolean unique,
                                    boolean onDemand,
                                    boolean indexed,
                                    boolean dynColumn,
                                    java.lang.String dataSourceName,
                                    java.lang.String selectGroup,
                                    java.lang.String refTypeName,
                                    boolean multiRow,
                                    java.lang.String reverseProperty,
                                    java.lang.String dbDefault,
                                    java.lang.String ownerTypeName)
    • Method Detail

      • start

        public void start()
      • getPropertyMapper

        public IBeanMapper getPropertyMapper()
      • toString

        public java.lang.String toString()
        toString in class java.lang.Object
      • getTableName

        public java.lang.String getTableName()
      • isId

        public boolean isId()
      • getNumColumns

        public int getNumColumns()
      • eagerJoinForTypeId

        public boolean eagerJoinForTypeId​(sc.db.SelectTableDesc tableDesc)
      • getNumResultSetColumns

        public int getNumResultSetColumns​(sc.db.SelectTableDesc tableDesc)
      • getColumnName

        public java.lang.String getColumnName​(int colIx)
      • getColumnType

        public java.lang.String getColumnType​(int colIx)
      • resetTable

        public void resetTable​(TableDescriptor mainPropTable)
        This is called when we determine that this property's value is derived from the table provided. If this table is already an aux table, or one-to-many relationship, this property's table takes the name of the other table. If it is a primary table for this type, need to create a new aux/multi table If this is a many-to-many relationship, both tables get reconfigured to use the property names as the id columns although each table uses the opposite column for the id
      • getValueFromResultSet

        public java.lang.Object getValueFromResultSet​(java.sql.ResultSet rs,
                                                      int rix,
                                                      sc.db.SelectTableDesc selectTable,
                                                      IDBObject inst,
                                                      ResultWrapper logRefIdResult)
                                               throws java.sql.SQLException
      • updateReferenceForPropValue

        public void updateReferenceForPropValue​(java.lang.Object inst,
                                                java.lang.Object propVal)
      • getValueFromResultSetByName

        public java.lang.Object getValueFromResultSetByName​(java.sql.ResultSet rs,
                                                            java.lang.String colName)
                                                     throws java.sql.SQLException
      • getDataSourceForProp

        public java.lang.String getDataSourceForProp()
      • getRefColTypeDesc

        public DBTypeDescriptor getRefColTypeDesc()
        If this is an id property, returns the type of that id. For a reference column, returns the type of the reference.
      • getSubDBColumnType

        public DBColumnType getSubDBColumnType​(java.lang.String propPath)
      • getDBDefaultValue

        public java.lang.Object getDBDefaultValue()
      • ownedByOtherType

        public boolean ownedByOtherType​(DBTypeDescriptor otherTypeDesc)
      • getPropertyType

        public java.lang.Object getPropertyType()
      • getNeedsRefId

        public boolean getNeedsRefId()
        For single-valued association properties, we add a property propNameRefId to store the id
      • setRefIdProperty

        public void setRefIdProperty​(IDBObject obj,
                                     java.lang.Object idVal)
      • getRefIdProperty

        public java.lang.Object getRefIdProperty​(IDBObject inst)
      • hasValidator

        public boolean hasValidator()
      • validate

        public java.lang.String validate​(DBObject dbObj,
                                         java.lang.Object propVal)
      • getNeedsReferencesConstraint

        public boolean getNeedsReferencesConstraint()
      • isMultiRowProperty

        public boolean isMultiRowProperty()
      • isJsonReference

        public boolean isJsonReference()
      • stringToValue

        public java.lang.Object stringToValue​(java.lang.String strVal)