# Entity Attribute Settings

You can specify the following settings for an entity attribute. They are listed in the order that they appear in the Attribute Settings page of the wizards and editors.

### Name attribute setting

This setting appears in the Attribute Settings page of the View Object Wizard and Editor and the Entity Object Wizard and Editor, and in the Attribute Editor.

The required attribute name setting specifies the unique name that the attribute is referenced by in the Business Components for Java wizards, the Java source code, and the XML files.

### Type attribute setting

This setting appears in the Attribute Settings page of the View Object Wizard and Editor, the Entity Object Wizard and Editor, and the Domain Wizard and Editor, and in the Attribute Editor. All Java variables have a type, and the type restricts the kinds of objects that can be assigned to it.

For an entity object attribute, this setting is the Java data type or domain type of the attribute. You can also specify a Database Column Type, which is the SQL datatype of the database column; it is used to derive the default Java JDBC type at runtime. The SQL data type must correspond the Java data type, or you can get runtime exceptions, particularly for string conversions. During forward generation, the Database Column Type becomes the column type in the database.

For a view object attribute, this setting is the Java data type or domain type of this attribute. For persistent and entity-derived attributes, you can't change the type from that specified in the corresponding entity attribute.

For a domain, this setting is the Java type of the domain's mdata field.

If an attribute is of a domain type, and the Database Column Type attribute setting is set in the domain, you cannot override the setting in the Entity Object Wizard or Editor.

### Default Value attribute setting

This setting appears in the Attribute Settings page of the Entity Object Wizard and Editor and the Domain Wizard and Editor, and in the Attribute Editor.

For an entity object attribute, this setting is an optional default value. When the business logic tier creates a new row containing that attribute, the attribute gets this value by default.

For a domain, this default value is inherited by all attributes of this domain type and cannot be changed in the Entity Object Wizard or Editor or in the Attribute Editor.

### Primary Key attribute setting

This setting appears in the Attribute Settings page of the Entity Object Wizard and Editor and Domain Wizard and Editor, and in the Attribute Editor. For an entity object attribute, when selected, this attribute is (or is part of) the entity object's primary key. (More than one attribute can make up a primary key.) At least one attribute in an entity object must be defined as a primary key attribute.

If an attribute is of a domain type, and the Primary Key attribute setting is set in the domain, you cannot override the setting in the Entity Object Editor.

### Mandatory attribute setting

This setting appears in the Attribute Settings page of the Entity Object Wizard and Editor and the Domain Wizard and Editor, and in the Attribute Editor.

When selected, each entity object row must have a non-null value for this attribute. If it does have a null value, the row is considered to be invalid when you navigate away from it or try to commit.

If an entity attribute is of a domain type, and the Mandatory attribute setting is set in the domain, you cannot override the setting in the Entity Object Wizard or Editor or Attribute Editor.

### Persistent attribute setting

This setting appears in the Attribute Settings page of the Entity Object Wizard and Editor and the Domain Wizard and Editor, and in the Attribute Editor.

For an entity object attribute, select this setting to make the attribute persistent (the entity saves it in persistent storage — the database). Deselect it for a transient attribute.

If an attribute is of a domain type, and the Persistent attribute setting is set in the domain, you cannot override the setting in the Entity Object Wizard or Editor or Attribute Editor. So for transient attributes, Persistent should be not selected in the domain.

### Updateable attribute setting

This setting appears in the Attribute Settings page of the View Object Wizard and Editor, the Entity Object Wizard and Editor, and the Domain Wizard and Editor, and in the Attribute Editor. This setting determines whether you can call a setAttribute method on an attribute. An attribute must have one of the following Updateable settings:

- Always — The selected attribute may be updated in the business logic tier's cache.

- While New — The attribute can be updated only while the object is new: before the first time it is committed. After it is committed to the database, this attribute becomes read-only.

- Never — The attribute cannot be updated using the framework. Tip: you might want to consider removing the setter methods.

For a persistent or entity-derived view attribute, the updateability of the attribute can be restricted further than that of the corresponding entity attribute, but it can't be made "more updateable." So if the entity attribute setting was Never, but the view attribute setting was Always, the setting would remain Never. The same principle applies if an attribute is of a domain type.

### Refresh After attribute setting

This setting appears in the Attribute Settings page of the Entity Object Wizard and Editor and the Domain Wizard and Editor, and in the Attribute Editor.

A persistent entity object attribute can optionally have one or both of the following settings:

- Refresh After Update — After the entity object performs an update (the data in an entity object instance is placed in an existing row in the database), the entity object retrieves the value of the attribute from the corresponding database field. So the effect of any database triggers or procedures will be reflected back in the entity cache. For example, if you have a Date Updated field, after a row update, the database adds the new update date to the field, so the entity object instance needs the new value.

- Refresh After Insert — After the entity object inserts a new row in the database, the entity object retrieves the value of this attribute from the corresponding database field. For example, you can use this feature to assign primary key values from a sequence in a database trigger (after insert, the database generates the sequence number and the entity object retrieves the new attribute value).

If an attribute is of a domain type, and the Refresh After attribute setting is set in the domain, you cannot override the setting in the Entity Object Wizard or Editor.

### Queriable attribute setting

This setting appears in the Attribute Settings page of the View Object Wizard and Editor, the Entity Object Wizard and Editor, and the Domain Wizard and Editor, and in the Attribute Editor.

For an entity object attribute, when selected, the attribute can participate in a view object's query condition. If not selected, the information cannot be queried (BLOB types, for example).

For a view object attribute, when selected, the attribute can participate in a query condition. For a persistent attribute, if the columns (to which attributes of this type are mapped) can be part of a query filter (a WHERE clause), then this setting should be selected. For example, this property should be selected for NUMBER column types, but not set for BLOB types. This attribute will be suppressed from Query by Form interfaces.

If an attribute is of a domain type, and the Queriable attribute setting is set in the domain, you can override the setting in the View Object Wizard or Editor, but not in the Entity Object Wizard or Editor.

### Unique attribute setting

This setting appears in the Attribute Settings page of the Entity Object Wizard and Editor and the Domain Wizard and Editor, and in the Attribute Editor.

For a persistent entity object attribute, when this setting is selected, there can be only one row with a certain value (each row has a unique value in this column). During forward generation, the corresponding not null database constraint is created.

If an attribute is of a domain type, and the Unique attribute setting is set in the domain, you cannot override the setting in the Entity Object Wizard or Editor.

### Change Indicator attribute setting

This setting appears in the Attribute Settings page of the Entity Object Wizard and Editor and in the Attribute Editor. For a persistent entity object attribute, selecting this setting means that the attribute is used to determine whether any persistent attribute in the entity object has changed. The first time the user changes the value of an attribute in a row, the business logic tier attempts to lock the row (pessimistic locking mode) or tries to commit (optimistic locking mode); at this time, it checks whether the data values in its cache match the database. The Change Indicator attribute setting determines whether the business logic tier checks a single attribute or multiple attributes, which involves more overhead. So, a change in the attribute value between when the data is first brought into the entity object instance in the cache and when the data is first modified is used to indicate that the entire row has been changed by another user. Only one attribute in an entity object can have this setting. Often, the attribute is a time stamp column or a sequence number.

Related topics
What is an Entity Attribute?
What Is an Entity Object?
What is a View Attribute?