Showing posts with label Entity Object. Show all posts
Showing posts with label Entity Object. Show all posts

Thursday, 12 December 2019

oracle.jbo.DeadEntityAccessException: JBO-27101. Resolved! Attempt to access a dead Entity in EntityObject.


Error : oracle.jbo.DeadEntityAccessException: JBO-27101

Description: Attempt to access a dead entity in the Entity Object.

Root cause: This issue comes up when the application is trying to access a row that is already removed from the entity object cache. Suppose a row is being deleted in a method and then at the end, the same row is being referenced for doing some kind of operation.
 
The error normally comes up due to wrong implementation logic written in

public void doDML(int operation, TransactionEvent e)

method of EntityImpl class. This method runs after every DML operation in the row.
On removing the row also, this method will be called and if some logic is written there such as updating some attribute values of that row without checking for the transaction type, then this error may come up.

Here is an example of the wrong implementation:

    protected void doDML(int operation, TransactionEvent e) {
        super.doDML(operation, e);
        setModifiedOnDt(new Date());   
    }

Right Implementation:

    protected void doDML(int operation, TransactionEvent e) {
        super.doDML(operation, e);
        if(operation == DML_UPDATE){
            setModifiedOnDt(new Date());   
        }
    }

If the above is not your use case, then here is another example

Another example just to simulate this error:

    public void updateRecord(){
        Row currentRow = getEmployeeVO1().getCurrentRow();
        currentRow.remove();
        // oracle.jbo.DeadEntityAccessException: JBO-27101 Error will be shown in the code below
        Object empId = currentRow.getAttribute("EmployeeId");
    }
 
Solution:
The solution is to ensure that if any row is deleted then it should not be referenced after the deletion.

Next: What is the use of EntityImpl in ADF??

Wednesday, 11 December 2019

What is EntityImpl class in ADF?

EntityImpl is the implementation class of EntityObject which represents a row which currently there in EntityObject Cache. The row may be a row from a database table or a new Row which is created from the Application.
EntityImpl in oracle ADF

There are a few methods which there in EntityImpl and they are quite useful in the development.

1. public void create (): This method is called whenever a new row is created from the Application. Here we can implement logic to set default values that are needed when a row is created.

Example Logic which can be implemented: 

Suppose you need to store the information about when and by which user a row is being Created. You can implement the logic here. Here in this method, you can write the code to set UserId and CreateDate, the values will be set at the creation of the Row itself.

2. public void doDML(int operation, TransactionEvent e):   This method is called whenever there is any kind of DML operation is going on in the Row. It contains a parameter operation that represents which kind of operation is being done. The operations can be
    DML_INSERT: Insert operation is being done.
    DML_UPDATE: Update on the Entity Row is being done
    DML_DELETE: Delete operation is being done.

Example Logic which can be implemented:

On any update of the Row, we can implement the logic to set the Modified Username and Modified date of the row
  
3. public void remove():  This method is called whenever a row is deleted for removed from the EntityObject.

Example Logic which can be implemented:

Supposed you need to check if there are any child records for the existing current records or not. This logic can be written here.

Saturday, 30 November 2019

What is an Entity Object in Oracle ADF?

EntityObject in ADF represents an individual Object in the data source. Such as database Tables. It contains all the properties of the database table.

Analogy: EntityObject in oracle ADF represents a table in the database which stores the data.


Entity Object contains all the properties of the database table, such as Database Constraints, Primary Keys, Foreign Keys, etc. and also table column properties such as Columns, Column Type, Column Precision Scale, Column Default Value, etc.

Entity Object is responsible for facilitating DML operation in database tables. Before it pushes the data in the database it validates with all the constrains of the database table and ensures that all the data it is sending in the data is correct. This helps in avoiding any corrupt data posting in the database. This helps in reducing database calls and adds to the real-time performance of the Application.