An attribute is a 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 two kinds of entity attributes:
Attribute kind |
Value derived from a database query? |
Persisted in the database? |
persistent |
yes |
yes (the value outlives the class that created it) |
transient |
no |
no |
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.
For forward generation, when you create database tables from entity objects, each persistent attribute becomes a column in the table.
While creating or editing an entity object, you specify attribute settings. The settings can affect forward generation or the settings can be derived from an existing table (reverse generation). The following table summarizes what settings affect forward and reverse generation, and which settings apply to persistent and transient attributes.
Attribute Setting |
Forward Generation |
Reverse Generation |
Persistent Attribute |
Transient Attribute |
N/A |
Default based on column name; you can change it to any Java identifier name. |
Required |
Required |
|
N/A |
Default based on column data type; you can choose another type in the list. |
Required |
Required |
|
N/A |
N/A |
Optional |
Optional |
|
Becomes the table's primary key, or part of it if you specify multiple primary keys for a table (a composite key) |
From the table; it must match the table. |
Selectable |
Selectable, but you should leave it deselected in most cases |
|
Becomes a mandatory column in the table (a NOT NULL constraint is generated for that column in the table). |
From the table; this value must match the table, or you might get problematic runtime behavior or an exception. |
Selectable |
Selectable |
|
Only persistent attributes are added to the table. |
All attributes derived from the table are persistent; if you change it, this column does not get populated through the business components framework. |
Selected |
Deselected |
|
N/A |
N/A |
Selectable |
Selectable |
|
N/A |
N/A except when the java.sql.type for this attribute is CHAR, then all Refresh After checkboxes are selected. |
Selectable |
N/A |
|
Becomes the table's column name |
From the table; it must match the table. |
Required; it must match the table. |
N/A |
|
Becomes the table's column data type |
From the table; it must match the table. |
Required; it must match the table. |
N/A |
|
N/A |
N/A |
Selectable |
N/A |
|
If selected, the column has a unique constraint. |
From the table; it must match the table. |
Selectable |
N/A |
|
N/A |
N/A |
Selectable |
N/A |
In general, if you are performing reverse generation, you don't want to change the primary key, mandatory, database column name, column type, and unique settings that were received from the table. For forward generation, the primary key, mandatory, persistent, database column name, column type, and unique settings are used to generate tables.
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.
Related topics
Entity Attribute Settings
What Is an Entity Object?
About Generating
Entity Objects, Associations, and Database Tables
What is a View Attribute?