Using a method validator based on a view object accessor
In this recipe, we will show how to validate an entity object against a view accessor using a custom entity method validator. The use case that we will cover—based on the HR
schema—will not allow the user to enter more than a specified number of employees per department.
Getting ready
We will be using the HRComponents
workspace that we created in the previous recipes in this chapter so that we don't repeat these steps again. You will need access to the HR
database schema.
How to do it…
1. Right-click on the
com.packt.jdeveloper.cookbook.hr.components.model.view
package of theHRComponentsBC
business components project of theHRComponents
workspace, and select New View Object….2. Use the Create View Object wizard to create a SQL query view object called EmployeeCount based on the following query:
SELECT COUNT(*) AS EMPLOYEE_COUNT FROM EMPLOYEES WHERE DEPARTMENT_ID = :DepartmentId
3. While on the Create View Object wizard, also do the...