Tuesday, May 19, 2015

ADF Entity object

ADF Entity object
The options for an entity object are changed in the Overview tab. Some settings related to
attributes can be changed using the Property Inspector window. Let us explore the options
under the entity object.
General
Some general settings for the entity object are as follows:
‹ Name: This section displays the name of the entity object. This section is editable,
and changing the name will affect all the artifacts related to the entity object.
‹ Package: This section displays the package for the entity object. The pencil icon
next to the option will help to change or refactor the value.
‹ Extends: This option is used to extend another entity object. The extended entity
will become the parent of the current entity. A window will be shown to the user
to select the parent entity.
For example, if you have SalesAccountEO and CustomerAccountEO, then these
two entity objects can extend the AccoutEO to inherit the common features.
‹ Property Set: We can have properties and messages defined as a named-value pair
in property sets. Property sets are created from the New Gallery wizard under the
ADF Business Components section.
‹ Schema Object: This is the actual name of the table. The pencil icon will help the
user to select the schema object from the database if the user decides to change
the table associated with the entity object.
Alternate key
We can create an alternate key, other than a primary key, to uniquely identify a row.
The alternate key will usually be defined on an attribute other than the primary key.
For example, alternate keys can be defined on a Name attribute for uniqueness.
Tuning
The tuning settings are as follows:
‹ Use Update Batching: This setting is used to update the entities in a batch when
the number exceeds the number provided in the space available. For example,
if the entity is getting updated from multiple sources, then this option will enable
us to issue a single collective DML statement for bulk CRUD operation. Using this
property will reduce the number of statements getting generated.
‹ Retain Association Accessor Rowset: This setting is used to tell the instance of
an entity object to retain the accessor rowset, when accessing the object using an
association. The rowset is created every time an access is made through association.
Setting this property will retain the source accessor rowset for performance instead
of creating it every time.
‹ Custom Properties: You can add some properties here, defined as named-value pair,
to be assessed at runtime.
Security
You can set the security for the entity object using the Read, Update, removeCurrentRow
option. You need permissions to be added to the jazn-data.xml file to read data through
an entity if the options were selected.
Business Logic Group
This is helpful if you want to store properties, control hints, validations, localizations, and
messages based on a group. The logical group needs a business logical unit, which will be
loaded at runtime based on the value of the discriminator.
Attributes
The options listed in this section are specific for the entity object attributes, which is updated
using the Property Inspector window. You can select the attribute from either the structure
window or the Overview tab.
Details
‹ Name: This setting displays the actual name of the attribute. The column name
of the table is represented in a CamelCase for the entity object.
‹ Display Name: This is the display name for the attribute that will be shown in
the business component diagram.
‹ Description: A description for the attribute is added in this section.
‹ Type: This setting displays the data type of the attribute. Some of the common
types are java.lang, Integer, java.lang.String, oracle.jbo.domain.
Timestamp, and so on. These are the types that correspond to the database
column type VARCHAR2, NUMBER, and DATE, respectively.
‹ Property Set: This is the property set that has to be applied to the attribute.
‹ Default Value: You can provide a default value for the attribute using this setting.
‹ Literal: The default value will be a literal value.
. Expression: This setting lets you default the attribute to an expression. Groovy expression language is used to define the expression. Groovy is a Java-like language used for scripting.
. Refresh Expression Value: This is the condition provided to recalculate the expression value.
. SQL: This setting lets you default to the output of an SQL query.
. Polymorphic Discriminator: Checking this option makes the attribute the discriminator column, which is used to identify the type of the entity object we already knew we are working with and it also identifies the entity object that is extended from a parent entity object.
. Effective Date: This is related to the Effective Date functionality to get the information at a particular time. Sometimes information may change during a single day, so to keep track of the change in information, we use this option.

For an effective date, you would need a column representing a start date, an end date, a sequence, and a sequence flag. These attributes are mapped to the corresponding available options.
. Start Date: This is the attribute with a start date
. End Date: This is the attribute with an end date
. Sequence Flag: This is the attribute mapped for a sequence flag
. Sequence: This is the attribute mapped for the sequence

. Updateable: This sets the attribute as updateable. If this is not checked, then the attribute value cannot be updated and trying to update it will result in an exception. The following options will define when the attribute should be updateable: . Always: This option defines that the attribute is always updateable.
. While New: This option defines that the attribute is updateable only when the attribute is newly created or initialized.
. Never: This option defines that the attribute can never be updated. The attribute will be displayed as read-only in the UI.

. Persistent: This option defines if the attribute value should be stored in the database.
. Transient: This option defines that the attribute value is not persisted to the database and is used to calculate the values in the middleware layer.
. Mandatory: This option sets the attribute as required. If the attribute is not given a value, then ADF will prompt to provide a value for this attribute.
. Primary Key: This option sets the current attribute as a primary key.
. Queriable: This option sets the attribute to take part in a query. If this option is not set, then the attribute will not be displayed in the UI as a queriable attribute.
. Refresh on Insert: This is a trigger which causes the attribute to refresh from the database when a new row is inserted.
. Refresh on Update: This option causes the attribute to be refreshed when the row is updated.
. Change Indicator: This option sets the attribute as the change-indicator value, which will help in versioning the row.
. Precision Rule: This option is used to set a strict precision rule.
. Track Change History: This option is used to have a version number for history columns created on, created by, modified on, modified by, and version number.
. Column Name: This option defines a column name in the database.
. Column Type: This option defines the data type of the column.
UI Hints
‹ Display Hints: This option defines whether to display the attribute or hide it in the UI.
‹ Label: This option defines the label to be displayed for the attribute in the UI.
‹ ToolTip: This option defines if you want to show any tip.
‹ Format Type: This option defines the format for date field; for example, Simple Date.
‹ Format: This option defines the format pattern for the date.
‹ Control Type: This option defines the display control hints such as checkbox, date,
image, and others.
‹ Display Width: This option defines the display width for the attribute when
displayed in the UI.
‹ Display Height: This option defines the height of the field in the UI.
‹ Form Type: This option causes the attribute to be displayed in summary when it is
shown in a form.
‹ Auto submit: This option can be set to true or false in order to refresh the
dependent component based on this attribute.
Validation Rule
You can set validation for the attribute. The business logic can be set declaratively in
this section. Some of the validations are Compare, Range, regular expression, Script,
and so on.
Security
This setting defines restrictions for updating the attribute.
Dependencies
This setting is used to select the attribute on which the current attribute is dependent on
for recalculation or database refetch.
Custom Properties
You can add custom properties to access at runtime.
Business Rules
You can set the business validation and rules here, same as the validation rule section in
the attribute. Here, you can set the business rule for the complete entity. The two extra
validations available here are Collection and UniqueKey.
---

---
Java
If you want to add a Java class for your entity object, you can add it here. There are three types of Java classes that you can add. They are as follows:
. Entity object class: This class contains the accessor information
. Entity collection class: This class maintains the entity collection
. Entity definition class: This class will refer to the definition of an entity
Business Events
This section is used to raise events based on some business operation. For example, we have to notify some other application or service if a row is inserted into the database. We can publish an event from this section using the payload.
View Accessor
This section is used to provide a list source for the attribute. For example, you would want to show the department names as a list option instead of showing the department ID.
Association
Some important settings for the association are explained in this section.
Relationship
The Behavior section is used to specify the behavioral aspect of the association. Some of the behavior's settings are:
. Use Database Key constraints: Selecting this property will make sure that the database constraint is added to the source and target entity objects.
. Composition Association: The composition association is enabled between the entity objects. This option is helpful for master-detail mapping with one-to-many relationships. This setting will make sure that the parent-child relation remains intact and works properly.

The following options will be enabled only for Composition Association.
. Optimize for Database Cascade Delete: This setting will make sure that the Cascade Delete option works fine for parent-child relationships and optimizes the deletion of the child objects row when the parent entity objects are deleted.

‰ Implement Cascade Delete: This option will be enabled only if the previous
option is not chosen. This will make sure that all the child entity object
records are deleted before deleting the parent entity.
‰ Cascade Update Key Attributes: This setting will update the foreign key
attribute in cascade when the parent key changes.
‰ Update Top-level History Columns: This setting will update the parent's
history columns before updating the child's records.
‰ Lock Level: This option will determine at which level the lock has to be
applied during the UPDATE operations.
‰ Lock Container: This will lock the container of the entity for which the
framework acquires the lock.
‰ Lock Top-level Container: The framework will lock the top-most entity in
the composition hierarchy when the child entity object is locked for the
UPDATE operation.

No comments:

Post a Comment