Package org.apache.cayenne.map
Class DbAttribute
- java.lang.Object
-
- org.apache.cayenne.map.Attribute
-
- org.apache.cayenne.map.DbAttribute
-
- All Implemented Interfaces:
Serializable,ConfigurationNode,CayenneMapEntry,XMLSerializable
public class DbAttribute extends Attribute 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 intattributePrecisionprotected booleangeneratedDefines whether this column value is generated by the database.protected booleanmandatoryDefines whether the attribute allows nulls.protected intmaxLengthprotected booleanprimaryKeyDefines whether the attribute is a part of the table primary key.protected intscaleprotected inttypeDefines JDBC type of the column.
-
Constructor Summary
Constructors Constructor Description DbAttribute()DbAttribute(String name)DbAttribute(String name, int type, DbEntity entity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> TacceptVisitor(ConfigurationNodeVisitor<T> visitor)voidencodeAsXML(XMLEncoder encoder, ConfigurationNodeVisitor delegate)Prints itself as XML to the provided XMLEncoder.StringgetAliasedName(String alias)intgetAttributePrecision()DbEntitygetEntity()Returns parent entity that holds this attribute.intgetMaxLength()Returns the length of database column described by this attribute.intgetScale()Returns the number of digits after period for decimal attributes.intgetType()Returns the SQL type of the column.booleanisForeignKey()Returnstrueif the DB column represented by this attribute is a foreign key, referencing another table.booleanisGenerated()Returns true if this column value is generated by the database.booleanisMandatory()booleanisPrimaryKey()voidsetAttributePrecision(int attributePrecision)voidsetGenerated(boolean generated)Updates attribute "generated" property.voidsetMandatory(boolean mandatory)voidsetMaxLength(int maxLength)Sets the length of character or binary type or max num of digits for DECIMAL.voidsetPrimaryKey(boolean primaryKey)Updates attribute "primaryKey" property.voidsetScale(int scale)voidsetType(int type)Sets the SQL type for the column.StringtoString()
-
-
-
Field Detail
-
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
-
-
Method Detail
-
getEntity
public DbEntity getEntity()
Description copied from class:AttributeReturns parent entity that holds this attribute.
-
acceptVisitor
public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor)
- Specified by:
acceptVisitorin interfaceConfigurationNode
-
encodeAsXML
public void encodeAsXML(XMLEncoder encoder, ConfigurationNodeVisitor delegate)
Prints itself as XML to the provided XMLEncoder.- Specified by:
encodeAsXMLin interfaceXMLSerializable- Specified by:
encodeAsXMLin classAttribute- Since:
- 1.1
-
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()
Returnstrueif 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
-
-