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

# Class ObjAttribute

java.lang.Object
org.apache.cayenne.map.Attribute<ObjEntity, ObjAttribute, ObjRelationship>
org.apache.cayenne.map.ObjAttribute

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

Direct Known Subclasses:
  `EmbeddedAttribute`

public class ObjAttribute extends Attribute<ObjEntity, ObjAttribute, ObjRelationship> implements ConfigurationNode
An ObjAttribute is a mapping descriptor of a Java class property.

See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected CayennePath`
  `dbAttributePath`
  `protected boolean`
  `lazy`
  `protected String`
  `type`
  `protected boolean`
  `usedForLocking`

  ### Fields inherited from class Attribute

  `entity, name`
  Modifier and Type
  Field
  Description
  `protected Entity<ObjEntity, ObjAttribute, ObjRelationship>`
  `entity`
  `protected String`
  `name`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ObjAttribute()`
  `ObjAttribute(String name)`
  `ObjAttribute(String name, String type, ObjEntity entity)`
  `ObjAttribute(ObjAttribute attribute)`
  Creates a clone of an ObjAttribute argument.

- ## 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.
  `DbAttribute`
  `getDbAttribute()`
  Returns a DbAttribute mapped by this ObjAttribute.
  `String`
  `getDbAttributeName()`
  Returns the name of the mapped DbAttribute.
  `CayennePath`
  `getDbAttributePath()`
  Returns a dot-separated path that starts in the root DbEntity that maps to this attribute's ObjEntity and spans zero or more relationships, always ending in a DbAttribute name.
  `Iterator<CayenneMapEntry>`
  `getDbPathIterator()`
  `Iterator<CayenneMapEntry>`
  `getDbPathIterator(ObjEntity entity)`
  `ObjEntity`
  `getEntity()`
  Returns parent entity that holds this attribute.
  `Class<?>`
  `getJavaClass()`
  Returns Java class of an object property described by this attribute.
  `int`
  `getMaxLength()`
  Returns this attribute's maximum allowed length
  `String`
  `getType()`
  Returns fully qualified Java class name of the object property represented by this attribute.
  `boolean`
  `isFlattened()`
  Returns whether this attribute is "flattened", meaning that it points to a column from an entity other than the DbEntity mapped to the parent ObjEntity.
  `boolean`
  `isInherited()`
  Returns `true` if attribute inherited from a super entity.
  `boolean`
  `isLazy()`
  `boolean`
  `isMandatory()`
  Returns whether this attribute is mandatory
  `boolean`
  `isPrimaryKey()`
  `boolean`
  `isUsedForLocking()`
  Returns whether this attribute should be used for locking.
  `void`
  `setDbAttributePath(String dbAttributePath)`
  `void`
  `setDbAttributePath(CayennePath dbAttributePath)`
  `void`
  `setLazy(boolean lazy)`
  Sets whether this attribute should be loaded lazily.
  `void`
  `setType(String type)`
  Sets the type of the data object property.
  `void`
  `setUsedForLocking(boolean usedForLocking)`
  Sets whether this attribute should be used for locking.
  `String`
  `toString()`
  `void`
  `updateDbAttributePath()`
  Updates DbAttributePath for this ObjAttribute

  ### 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<ObjEntity, ObjAttribute, ObjRelationship> 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 String type

  - ### usedForLocking

    protected boolean usedForLocking

  - ### lazy

    protected boolean lazy
    Since:
      4.2

  - ### dbAttributePath

    protected CayennePath dbAttributePath

- ## Constructor Details

  - ### ObjAttribute

    public ObjAttribute()

  - ### ObjAttribute

    public ObjAttribute(String name)

  - ### ObjAttribute

    public ObjAttribute(String name, String type, ObjEntity entity)

  - ### ObjAttribute

    public ObjAttribute(ObjAttribute attribute)
    Creates a clone of an ObjAttribute argument.
    Since:
      3.0

- ## Method Details

  - ### getEntity

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

  - ### acceptVisitor

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

  - ### getJavaClass

    public Class<?> getJavaClass()
    Returns Java class of an object property described by this attribute. Wraps any thrown exceptions into CayenneRuntimeException.

  - ### 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<ObjEntity, ObjAttribute, ObjRelationship>`
    Since:
      1.1

  - ### getType

    public String getType()
    Returns fully qualified Java class name of the object property represented by this attribute.

  - ### setType

    public void setType(String type)
    Sets the type of the data object property. Type is expected to be a fully qualified Java class name.

  - ### isPrimaryKey

    public boolean isPrimaryKey()
    Since:
      3.0

  - ### isUsedForLocking

    public boolean isUsedForLocking()
    Returns whether this attribute should be used for locking.
    Since:
      1.1

  - ### setUsedForLocking

    public void setUsedForLocking(boolean usedForLocking)
    Sets whether this attribute should be used for locking.
    Since:
      1.1

  - ### isLazy

    public boolean isLazy()
    Returns:
      whether this attribute should be loaded lazily.
    Since:
      4.2

  - ### setLazy

    public void setLazy(boolean lazy)
    Sets whether this attribute should be loaded lazily.
    Since:
      4.2

  - ### getDbAttribute

    public DbAttribute getDbAttribute()
    Returns a DbAttribute mapped by this ObjAttribute.

  - ### isInherited

    public boolean isInherited()
    Returns `true` if attribute inherited from a super entity.
    Since:
      3.0

  - ### getDbPathIterator

    public Iterator<CayenneMapEntry> getDbPathIterator()

  - ### getDbPathIterator

    public Iterator<CayenneMapEntry> getDbPathIterator(ObjEntity entity)

  - ### getDbAttributeName

    public String getDbAttributeName()
    Returns the name of the mapped DbAttribute. This value is the same as "dbAttributePath" for regular attributes mapped to columns. It is equal to the last path component for the flattened attributes.

  - ### setDbAttributePath

    public void setDbAttributePath(String dbAttributePath)

  - ### setDbAttributePath

    public void setDbAttributePath(CayennePath dbAttributePath)

  - ### getDbAttributePath

    public CayennePath getDbAttributePath()
    Returns a dot-separated path that starts in the root DbEntity that maps to this attribute's ObjEntity and spans zero or more relationships, always ending in a DbAttribute name.

  - ### isFlattened

    public boolean isFlattened()
    Returns whether this attribute is "flattened", meaning that it points to a column from an entity other than the DbEntity mapped to the parent ObjEntity.
    Since:
      3.0

  - ### isMandatory

    public boolean isMandatory()
    Returns whether this attribute is mandatory
    See Also:
      - `DbAttribute.isMandatory()`

  - ### getMaxLength

    public int getMaxLength()
    Returns this attribute's maximum allowed length
    See Also:
      - `DbAttribute.getMaxLength()`

  - ### updateDbAttributePath

    public void updateDbAttributePath()
    Updates DbAttributePath for this ObjAttribute

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Attribute<ObjEntity, ObjAttribute, ObjRelationship>`