Business Components for Java provides a framework for defining, implementing, and executing validation logic in middle-tier components. The validation framework provides a consistent programming model that hides internal implementation details. It frees you to focus on rules that prevent users from entering invalid values into the database.
Note that validation is different from an integrity (or "database") constraint. An integrity constraint is a declarative way to define a business rule for a column of a table. Integrity constraints are defined with a table and are stored as part of the table's definition, centrally in the database's data dictionary, so that all database applications adhere to the same set of rules. You use integrity constraints when your clients do not use Business Components for Java.
You can define and apply validation logic by:
Using Domain Objects as data types for Entity Object attributes. A Domain Object validates data in its constructor. You can also apply rules and add code to a Domain Object's validate method to further refine the business logic. Domains can also be used to define a Java mapping for the Oracle Objects that appear in your relational tables. The Domain encapsulates the Oracle Object's value and represents it as a Java class.
Editing validation methods. The Business Components for Java framework generates setAttribute methods for Entity Objects (for example, Dept.setLoc), and the base Entity class provides a validateEntity method that your Entity Objects can override (for example, Dept.validateEntity). This is a purely code-based way of doing business logic using Business Components.
Applying validation rules to Entity Objects. JDeveloper provides wizards to define and apply simple rules without writing code. You can also implement more complex rules in custom validation classes. Then you can register the classes as validator types and apply them, the same as built-in rules. Validation rules encapsulate reusable patterns of validation that developers can use by supplying appropriate parameter values.
Creating Entity Constraints. An Entity constraint is a middle-tier object that represents a key constraint in the database. An Entity constraint describes, in terms of Entity Objects and attributes, the database-level relationships between tables and columns. You select the Entity Object's attributes and define the constraint in terms of database integrity constraints such as primary, foreign, check, or unique. When you create a database object based on an Entity Object, the definition of the Entity Constraint is used to detect associations between tables, create the specified key constraints in the database, and ensure that data in the database is valid and conforms to the key constraints.
The Business Components for Java framework supports various validation levels: you can validate attributes, entities, and the logical business objects. JDeveloper invokes validation logic at the appropriate level when data is created or changed, and assumes that data already in your tables is valid. A query could return a result set that contains invalid values (for example, from legacy data entered before the validation logic was applied), but a user cannot enter an invalid value into the table.