394 total views, 7 views today

About ADF Entity Object

ADF Entity Object is providing a gateway to do DML operation to database tables. In ADF, if a user does create/Delete/Update or any custom DML operation on tables then it most likely happens through Entity objects.

On the other hand, View Object is useful to view the records in the table,  most likely for Select Queries. So ,

Entity Object =  Add/Update/Delete record in a table

View Object =  Select record in table with Where and GroupBy  support 

In this section, I have explained how we can use Entity Object Java classes 

 

Pre-Requisite

JDeveloper 12.1.3

HR Schema (Comes with Oracle Database)

 

ADF Entity Object Example: 

 

I have already created an  Entity Object and its Java classes of Country table.  I used the  EO Java class in this example. 

 

1. As you see below, the generated Entity Object Java class has the below overridden methods

 

  • The Create() method executes whenever a row is inserted into the Country table (Here the record is residing in cache memory of ADF)
  • The remove() method executes whenever a row is deleted in Country table (The delete happens in cache memory of ADF )
  • The doDML() method executes whenever commit occurs for create/remove

 

050416_0329_AboutADFEnt1 About ADF Entity Object and its Java methods

 

 

2. We can add any custom Java code on each method so that the custom code execute before the actual override method executing. I have inserted a print statement on each method as shown below, the print statement will execute first whenever a row in Country table get Created/Updated or Deleted.  

 

050416_0329_AboutADFEnt2 About ADF Entity Object and its Java methods

 

Test the operation

1. ADF provides an easy way to test the Entity & View Objects without the need for creating a JSF page or deploying it on the server.

Right click on the App Module and click Run as shown below

 

050416_0329_AboutADFEnt3 About ADF Entity Object and its Java methods

 

2. App Module wizard will appear on the screen. Double click on the CountryEOView1. We can perform CRUD operation on this page 

 

  • Click the  +  icon to insert a record into Country table. JDeveloper console produce the following output when you insert a record 

                    Insert Statement Executed

  • Click X icon to delete a record in Country table. JDeveloper console produce the following output when you insert a record 

                           Delete Statement Executed

  • Click 050416_0329_AboutADFEnt5 About ADF Entity Object and its Java methods icon to commit the transaction to the database; you will receive the following 0otput in the JDeveloper console

                         Commit Occurs

 

050416_0329_AboutADFEnt4 About ADF Entity Object and its Java methods

 

 

 

 

Sometimes we may restrict users to delete any records from the table. We could achieve this by modifying the doDML operation like below

 

050416_0329_AboutADFEnt6 About ADF Entity Object and its Java methods

govindan About ADF Entity Object and its Java methods
Connect me

Govind

Thank you for visiting my personal blog. Myself Govindan, Software Developer by profession since 2006 and hence I started this blog early in 2016 and ever since I've been writing about technologies experienced and learnings of everyday life.

The views expressed on this blog are my personal views and do not necessarily reflect the views of my employer.

Please feeling free to reach me on any comments and feedbacks you have. Would be more than glad to listen and reply šŸ™‚
govindan About ADF Entity Object and its Java methods
Connect me
By | 2017-06-12T20:15:05+00:00 May 3rd, 2016|Categories: ADF|Tags: , , , , |0 Comments
Like us on Facebook.
Connect!