Software Engineering

Object Types in ADF 12c Using View And Entity Objects (Part 2 of 2)

This is the second part of the article how to work with Oracle PL/SQL object types using entity and view objects. You need the understanding and the project set up of the previous part, so work through this and come back here, if you didn’t do it already. In this part you will learn how to intercept the create, update and delete procedures of the entity object, so you really can use the view and entity object like you would use normal view and entity objects.


  • understanding of part 1
  • project set up of part 1
  • disable all triggers of HR.EMPLOYEES (otherwise they will intercept sooner or later)
    • right click on HR.EMPLOYEES table -> Trigger -> Disable All… -> Apply

disable all triggers confirm disabling


Step By Step

Stored Procedures For Creating, Updating and Deleting

  • create the following stored procedures


Adapt the Entity Object

  • the doDML(…) method is the place to go, if you need to do custom stuff for creating, updating and deleting
  • override the doDML(…) method and create the following helper method

    • as you can see the helper method just adapts the string for the called procedure and always fills in the attribute values of the entity
  • you also need to override the doSelect(…) method
        • this method is either called with true or false
          • true: a lock on the row and a row consistency check are requested
          • false: a normal select on the database without a lock
        • to do the lock part, you can call a SELECT … FOR UPDATE statement in a stored procedure (or in a programmatic SQL statement)  — for an example see the following stored procedure

        • and stored procedure for the normal SELECT statement


    • now, override the doSelect(…) method

    • create the method to call stored procedures that return the attributes and a method that checks for inconsistency

    • next create a method that populates the results
        • the three booleans in the end enable the following features
          • first: tell listeners that a change occured
          • second: don’t mark the value as changed (dirty)
          • third: don’t save the old value
    • in the end, override the lock() method, too

      • the RowInconsistentException is caught (and later thrown again) to update the EO with the latest DB changes
      • this is a simple example what can happen, if inconsistency occurs -> adapt this part to your needs

Test the Methods

  • run the application module
  • create a new employee (make sure, you choose a valid job title! — e.g. copy it from an existing employee)
    run application module create a new employee
  • commit your changes to the database and play around with other functionality (deleting, updating)
  • follow the changes in the database
    follow your changes in the DB

Test It in a Page

  • create a new page in the ViewController
  • drag’n’drop EmployeeWithJobTitle1 from the Data Controls into the new page
  • add it as Table / List View -> ADF Table…
    • check Enable Sorting
    • check Enable Filtering
    • select Single Row under Row Selection
  • drag’n’drop  AppModuleAMDDataControl -> Operations -> Commit on the page as an ADF Button
  • drag’n’drop  AppModuleAMDDataControl -> EmployeeWithJobTitle1 -> Operations -> Delete   on the page as an ADF Button
  • drag’n’drop  AppModuleAMDDataControl -> EmployeeWithJobTitle1 -> Operations -> Create   on the page as an ADF Button
  • run the page
  • play around
    page with the view object

 Pad Yourself on Your Shoulder

  • raise your left or right hand
  • move it over the opposite shoulder
  • gently but firmly move the hand up and down on the shoulder for at least 3 times

More information

> Object Types in ADF 12c Using View And Entity Objects (Part 1 of 2)