The "Unique Key Validator" is an entity level validator that ensures that primary key values for an entity object are always unique. For example, in the Employees table in the HR schema you can create a "Unique Key Validator" on the "EMPLOYEE_ID" (since this is the primary key) to ensure that an employee should have a unique employee id. If a key (in this example an employee id) is found in either the entity's cache or the database a "TooManyObjectsException" is thrown. Let's see how you can define a "Unique Key Validator" on the EMPLOYEE_ID column of the EMPLOYEES HR table.
I've created a new ADF Application "UniqueKeyValidatorDemo" using the "Fusion Web Application (ADF)" template and using the "Business Components from Tables" wizard I've created an Entity "EmployeesEO" based on the EMPLOYEES table, a view "EmployeesVO" based on the "EmployeesEO" entity and an Application Module "UniqueKeyValidatorAM".
You can create an alternate key using the entity's "General" tab. So in our case, let's create an alternate key for the "Email" attribute of the "EmployeesEO" entity object. Under the "Alternate Keys" section click on the green plus icon "Add Alternate Key".
Run your application module and update an employee's email with an existing email. For example, update Steven King's email to "NKOCHHAR". You should get an error message saying that the email is already in use.
Download sample application: Unique Key Validator