ADF Business Components in Depth
ADF Business Components in Depth
Allows you to make complex requests for data retrieval using SQL
pessimistic locking.
Has a powerful caching and data passivation system for increasing the
performance and scalability of applications
1. An XML file, which represents the portion of the entity object definition that
can be developed declaratively. Most of the information is that needed for
O/R mapping, but it can also contain simple validation rules,
called validators. For many entity objects, the XML file by itself is
sufficient. EmployeesEO.xml
فيها التعاريف االساسية الي بتحتاجها عشان تبني ال اوبجيكت.
1. Persistent attributes are those attributes that do map to data source object
columns.
2. Transient attributes are all those attributes that do not map to data source object
columns. Transient attributes may be derived from information in a database, and
are often used for temporary storage and retrieval.
The values of entity attributes can be read and changed in one of two ways:
EntityImpl is the (data object) that: (represents a single row (or instance)) of
data in the business object layer.
o For example, if you have an Employee entity, an( EntityImpl object will
represent a single row in the Employee database table). (It holds the
attribute values for this particular instance of data, such as id, name,
salary, etc.)
EntityImpl (is responsible for the data management of this specific row), such
as:
o :((Persisting the row (e.g., executing save() to commit the changes to the
database).)
In short, EntityImpl is (the row of data and the object you interact with in your
application to manipulate that data. ) It represents (a single business object
instance (a row in the database table).)
The framework will automatically create entity instances based on the
metadata(XML) and handle the database operations for you.
Let’s break down how this works and what happens when you don’t directly
extend the Entity Object class.
In ADF, (Entity Objects represent rows from the data source (like a database
table).) (The metadata that describes the entity’s attributes), (relationships), and
(how it maps to the database) is (typically defined in XML) (or annotations in the
case of JPA).
The (XML configuration can describe how an Entity Object maps to a database
table and how it behaves, but if you don’t extend the Entity Object class, ADF
can still generate the necessary functionality automatically) from this
metadata.
How Does ADF Create Instances of Entity Object Class (EO) Without
Extending It?
EntityImpl: By default, if you don't write a custom Entity Object class (i.e., don’t
extend oracle.jbo.server.EntityImpl),( ADF uses the oracle.jbo.server.EntityImpl
class as the base class for entity objects). (It manages basic operations like
fetching attributes, updating values, and supporting persistence operations.)
Metadata Handling: ADF can still create Entity Object instances based on the
metadata defined in XML (typically .xml files or .jpx files in ADF). (This metadata
file specifies the attributes, primary keys, and relationships for the entity), and
ADF uses this( XML file to construct the entity object dynamically during runtime.)
(The XML file provides the metadata for ADF to instantiate the entity class and assign
values to its attributes.)
Automatic Instantiation: Even if you don’t write a custom EntityImpl class, ADF
can instantiate the Entity Object using the default EntityImpl class and
populate it with data fetched from the database using the metadata defined in
the XML file.
Example:
Consider the following XML metadata that defines an Employee entity (mapped
to a database table):
(Without a Custom Entity Object Class: ADF uses the default EntityImpl
class and this XML metadata to create instances of the EmployeeEO entity,
manage its attributes, and handle its persistence operations automatically.)
You don’t need to write any Java code for the Entity Object itself.
(With Custom Entity Object Class: If you need to add business logic (like
validations, transformations, or calculated fields), you would create a custom
EmployeeEO class that extends EntityImpl. This custom class allows you to
implement methods for these operations.)
Entity Definition Class (ED)
why we need EntityDefImpl while we have xml file contains this information ?
XML files in Oracle ADF contain static metadata that defines the structure of your entities. This
includes things like:
Validation rules.
This metadata typically gets generated or provided by tools like JDeveloper when you create
your entities, and it is often stored in XML files (e.g., Employee.xml, Department.xml, etc.).
While the XML file contains the static definitions, EntityDefImpl is the runtime class that
processes this metadata and manages the interaction between the metadata (from the XML)
and entity objects (like EmployeeImpl, DepartmentImpl).
In simpler terms, EntityDefImpl acts as a runtime manager that reads the metadata from the
XML files and applies it to the live objects (the entity instances) during execution. The entity
objects (e.g., EntityImpl) interact with EntityDefImpl to perform operations such as inserting,
updating, deleting, and querying entities, and EntityDefImpl helps in managing the entity’s
metadata behavior at runtime.
Here are the key reasons why EntityDefImpl is required, even though XML files contain
metadata:
The XML files are static — they contain definitions of the entity and its structure.
However, they don’t actually know how to manage entities at runtime.
EntityDefImpl loads and interprets this static metadata during the application runtime
and provides the necessary logic for working with Entity Objects (Eo) in the context of
database transactions, business logic, and UI interactions.
For example:
It also determines how to map data from the XML definition to the database at runtime
(when performing CRUD operations).
o You can find out the type of each attribute or validate it dynamically based on the
metadata.
o You can find out the type of each attribute or validate it dynamically based on the
metadata.
When you perform CRUD operations (Create, Read, Update, Delete), EntityDefImpl is
responsible for providing the necessary functionality to translate those operations into
database queries (SQL). It knows how to map the entity’s attributes to database
columns.
Without EntityDefImpl, ADF would not have a way to dynamically understand how to convert
an entity's data (its attributes) into SQL statements or how to manage complex mappings like
relationships and associations.
If you need to customize the behavior of the metadata at runtime (e.g., dynamic
validation, custom mapping, etc.), EntityDefImpl allows you to do that.
o For example, you might want to modify or add custom logic when an entity is
saved or loaded. This can be done by extending EntityDefImpl and overriding its
methods.
The XML file cannot provide this level of flexibility because it’s just a static file that defines the
structure — it doesn’t allow you to add business logic or customize runtime behavior.
Entity Relationships
The XML file defines the relationship structure, but EntityDefImpl provides the runtime
behavior for maintaining these relationships, especially when entities are persisted in the
database.
o When you save an entity, EntityDefImpl helps manage how the changes should
be committed or rolled back as part of a transaction.
o EntityDefImpl works with ADF's cache to track and maintain the state of entities
across different requests or transactions, ensuring that the same entity isn’t
loaded multiple times unnecessarily.
The XML files define the structure of the entity (its attributes, associations, etc.), but
they are static and don’t have any behavior or logic attached to them.
EntityDefImpl is the runtime class that provides the functionality for interpreting and
managing that static metadata. It:
Thus, while the XML files are necessary for defining the structure, EntityDefImpl is crucial for
providing the runtime functionality needed to make your entity data interact with the
database, handle operations, and support application logic dynamically.