DbAttribute (cayenne-doc: Cayenne Documentation 5.0-M2 API)
Description: declaration: package: org.apache.cayenne.map, class: DbAttribute

# Class DbAttribute

java.lang.Object
org.apache.cayenne.map.Attribute<DbEntity, DbAttribute, DbRelationship>
org.apache.cayenne.map.DbAttribute

All Implemented Interfaces:
  `Serializable, ConfigurationNode, CayenneMapEntry, XMLSerializable`

public class DbAttribute extends Attribute<DbEntity, DbAttribute, DbRelationship> implements ConfigurationNode
A DbAttribute defines a descriptor for a single database table column.

See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected int`
  `attributePrecision`
  `protected boolean`
  `generated`
  Defines whether this column value is generated by the database.
  `protected boolean`
  `mandatory`
  Defines whether the attribute allows nulls.
  `protected int`
  `maxLength`
  `protected boolean`
  `primaryKey`
  Defines whether the attribute is a part of the table primary key.
  `protected int`
  `scale`
  `protected int`
  `type`
  Defines JDBC type of the column.

  ### Fields inherited from class Attribute

  `entity, name`
  Modifier and Type
  Field
  Description
  `protected Entity<DbEntity, DbAttribute, DbRelationship>`
  `entity`
  `protected String`
  `name`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DbAttribute()`
  `DbAttribute(String name)`
  `DbAttribute(String name, int type, DbEntity entity)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `<T> T`
  `acceptVisitor(ConfigurationNodeVisitor<T> visitor)`
  `void`
  `encodeAsXML(XMLEncoder encoder, ConfigurationNodeVisitor delegate)`
  Prints itself as XML to the provided XMLEncoder.
  `String`
  `getAliasedName(String alias)`
  `int`
  `getAttributePrecision()`
  `DbEntity`
  `getEntity()`
  Returns parent entity that holds this attribute.
  `String`
  `getJavaClass()`
  `int`
  `getMaxLength()`
  Returns the length of database column described by this attribute.
  `int`
  `getScale()`
  Returns the number of digits after period for decimal attributes.
  `int`
  `getType()`
  Returns the SQL type of the column.
  `boolean`
  `isForeignKey()`
  Returns `true` if the DB column represented by this attribute is a foreign key, referencing another table.
  `boolean`
  `isGenerated()`
  Returns true if this column value is generated by the database.
  `boolean`
  `isMandatory()`
  `boolean`
  `isPrimaryKey()`
  `void`
  `setAttributePrecision(int attributePrecision)`
  `void`
  `setGenerated(boolean generated)`
  Updates attribute "generated" property.
  `void`
  `setMandatory(boolean mandatory)`
  `void`
  `setMaxLength(int maxLength)`
  Sets the length of character or binary type or max num of digits for DECIMAL.
  `void`
  `setPrimaryKey(boolean primaryKey)`
  Updates attribute "primaryKey" property.
  `void`
  `setScale(int scale)`
  `void`
  `setType(int type)`
  Sets the SQL type for the column.
  `String`
  `toString()`

  ### Methods inherited from class Attribute

  `getName, getParent, setEntity, setName, setParent`
  Modifier and Type
  Method
  Description
  `String`
  `getName()`
  Returns the name property of this object.
  `Object`
  `getParent()`
  Returns the parent map.
  `void`
  `setEntity(Entity<DbEntity, DbAttribute, DbRelationship> entity)`
  Sets parent entity that holds this attribute.
  `void`
  `setName(String name)`
  `void`
  `setParent(Object parent)`
  Stores the parent map.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### type

    protected int type
    Defines JDBC type of the column.

  - ### mandatory

    protected boolean mandatory
    Defines whether the attribute allows nulls.

  - ### primaryKey

    protected boolean primaryKey
    Defines whether the attribute is a part of the table primary key.

  - ### generated

    protected boolean generated
    Defines whether this column value is generated by the database. Other terms for such columns are "auto-increment" or "identity".
    Since:
      1.2

  - ### maxLength

    protected int maxLength

  - ### scale

    protected int scale
    Since:
      3.0

  - ### attributePrecision

    protected int attributePrecision
    Since:
      3.0

- ## Constructor Details

  - ### DbAttribute

    public DbAttribute()

  - ### DbAttribute

    public DbAttribute(String name)

  - ### DbAttribute

    public DbAttribute(String name, int type, DbEntity entity)

- ## Method Details

  - ### getEntity

    public DbEntity getEntity()
    Description copied from class: `Attribute`
    Returns parent entity that holds this attribute.
    Overrides:
      `getEntity` in class `Attribute<DbEntity, DbAttribute, DbRelationship>`

  - ### acceptVisitor

    public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor)
    Specified by:
      `acceptVisitor` in interface `ConfigurationNode`

  - ### encodeAsXML

    public void encodeAsXML(XMLEncoder encoder, ConfigurationNodeVisitor delegate)
    Prints itself as XML to the provided XMLEncoder.
    Specified by:
      `encodeAsXML` in interface `XMLSerializable`
    Specified by:
      `encodeAsXML` in class `Attribute<DbEntity, DbAttribute, DbRelationship>`
    Since:
      1.1

  - ### getAliasedName

    public String getAliasedName(String alias)

  - ### getType

    public int getType()
    Returns the SQL type of the column.
    See Also:
      - `Types`

  - ### setType

    public void setType(int type)
    Sets the SQL type for the column.
    See Also:
      - `Types`

  - ### isPrimaryKey

    public boolean isPrimaryKey()

  - ### isForeignKey

    public boolean isForeignKey()
    Returns `true` if the DB column represented by this attribute is a foreign key, referencing another table.
    Since:
      1.1

  - ### setPrimaryKey

    public void setPrimaryKey(boolean primaryKey)
    Updates attribute "primaryKey" property.

  - ### isMandatory

    public boolean isMandatory()

  - ### setMandatory

    public void setMandatory(boolean mandatory)

  - ### getMaxLength

    public int getMaxLength()
    Returns the length of database column described by this attribute.

  - ### setMaxLength

    public void setMaxLength(int maxLength)
    Sets the length of character or binary type or max num of digits for DECIMAL.

  - ### isGenerated

    public boolean isGenerated()
    Returns true if this column value is generated by the database. Other terms for such columns are "auto-increment" or "identity".
    Since:
      1.2

  - ### setGenerated

    public void setGenerated(boolean generated)
    Updates attribute "generated" property.
    Since:
      1.2

  - ### getAttributePrecision

    public int getAttributePrecision()
    Since:
      3.0

  - ### setAttributePrecision

    public void setAttributePrecision(int attributePrecision)
    Since:
      3.0

  - ### getScale

    public int getScale()
    Returns the number of digits after period for decimal attributes. Returns "-1" if not set.
    Since:
      3.0

  - ### setScale

    public void setScale(int scale)
    Since:
      3.0

  - ### getJavaClass

    public String getJavaClass()
    Returns:
      java class guessed by the JDBC type of this attribute
    Since:
      5.0

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Attribute<DbEntity, DbAttribute, DbRelationship>`