ADF: Validate attribute value based on other entity’s attribute (Using Accessor).

ADF: Validate attribute value based on other entity’s attribute (Using Accessor).

Sometimes we need to validate attribute based on other entity’s attribute. In this post I’m using HR schema, there are master detail relationship between Jobs and Employees table. So when you will create Entity objects using these tables, association will create automatically using foreign key relationship or you can create it yourself.

As you can see in following image relationship defined between jobs and employees table using Association. And Accessor name are used to get attribute value in other entity. So you can get Jobs table attribute in Employees table using accessor name Jobs.

Jobs table contain MinSalary and MaxSalary attribute for each Job.

So here we are going to validate Salary attribute of Employees table. Salary must be less than or equal to Max salary as defined in Jobs table for each job type.

Groovy Expression allows to access attribute of other entity using accessor name. Following are steps to do the same-


  1. Add validation rule in Salary Attribute on employees table using Green Plus icon.
  2. On dialog window select
  • Type=Compare
  • Operator=LessOrEqualTo
  • Compare With=Expression


  1. And write expression MaxSalary where Jobs is accessor name and MaxSalary is attribute name of Jobs table.

  1. Then Go to Failure Handling tab and set error message. You can also use Accessor to give custom message to user as below image(source.Jobs.MaxSalary)


Sample Code

About Manish Pandey

Manish is a Project Leader at Jagran Prakashan Ltd, focused on Jdeveloper Fusion Web Application(specifically Oracle ADF). He shares his knowledge through the OTN Jdev/ADF Forum. He has written more than 50 article about Oracle ADF and Jdeveloper.

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.