# What is a View Attribute?

An attribute characteristic of an entity object or view object, implemented as a JavaBean property of the object class. An attribute can correspond to a database column, or be independent of a column. There are five kinds of attributes:

Attribute kind | Defined where? | Value derived from a database query? | Persisted in the database?
persistent | entity or view object level | yes | yes (the value outlives the class that created it)
transient | entity or view object level | no | no
entity-derived | view object level | no | no
SQL-derived | view object level | yes | no
dynamic | view object level, at runtime | no | no

Entity objects can have the following kinds of attributes:

- Persistent. A entity object attribute that is persisted in the database (the Persistent attribute setting is selected).

- Transient. A entity object attribute that is not persisted in the database (the Persistent attribute setting is deselected).

When you first create an entity object using reverse generation, a persistent entity attribute is created for each table column. After, if you change the table, you need to manually change the attribute.

View objects can have the following kinds of attributes:

- Persistent. A view object attribute based on a persistent entity attribute. The data is cached at the entity object level.

- Entity-derived. A view object attribute based on a transient entity attribute. The data is cached at the entity object level.

- Transient. A view object attribute that is not based on an entity attribute and does not contain a SQL expression. The data is cached at the view object level.

- SQL-derived. A view object attribute that is not based on an entity attribute and does contain a SQL expression. The data is cached at the view object level.

- Dynamic. A view object attribute that is created with the addDynamicAttribute method. You can use it to store information created at runtime that you want to store with the row data. It is used only by the view object that created it. Dynamic attributes are handled the same way as design time attributes. Attributes can be any Serializable object. The data is cached at the view object level.

The value of a SQL-derived attribute is the result of a SQL statement. For example, a YearsOfService attribute might be the difference between an employee's hire date in the database and the current date. Alternatively, you could create a transient attribute and write code to perform a calculation in a Java file to set its value. In general, using SQL-derived attributes is more efficient than performing data-intensive calculations in Java.

In Business Components for Java, the term attribute is based on the UML definition, not the XML definition. In UML, an attribute is a named property of a class that describes a range of values that instances of that class might hold.