xviii
11.9 Setting the Severity Level for Validation Exceptions .................................................... 11-35
11.10 Bulk Validation in SQL ................................................................................................ 11-35
12 Implementing Validation and Business Rules Programmatically
12.1 About Programmatic Business Rules ............................................................................. 12-1
12.1.1 Programmatic Business Rules Use Cases and Examples ......................................... 12-2
12.1.2 Additional Functionality for Programmatic Business Rules .................................... 12-3
12.2 Using Method Validators ............................................................................................... 12-3
12.2.1 How to Create an Attribute-Level Method Validator .............................................. 12-4
12.2.2 What Happens When You Create an Attribute-Level Method Validator ................ 12-5
12.2.3 How to Create an Entity-Level Method Validator ................................................... 12-6
12.2.4 What Happens When You Create an Entity-Level Method Validator ..................... 12-7
12.2.5 What You May Need to Know About Translating Validation Rule Error Messages 12-8
12.3 Assigning Programmatically Derived Attribute Values ................................................. 12-8
12.3.1 How to Provide Default Values for New Rows at Create Time ............................... 12-9
12.3.1.1 Choosing Between create() and initDefaultExpressionAttributes() Methods .... 12-9
12.3.1.2 Eagerly Defaulting an Attribute Value from a Database Sequence ................... 12-9
12.3.2 How to Assign Derived Values Before Saving ....................................................... 12-10
12.3.3 How to Assign Derived Values When an Attribute Value Is Set ........................... 12-11
12.4 Undoing Pending Changes to an Entity Using the Refresh Method ............................ 12-11
12.4.1 How to Control What Happens to New Rows During a Refresh .......................... 12-12
12.4.2 How to Cascade Refresh to Composed Children Entity Rows .............................. 12-12
12.5 Using View Objects for Validation ............................................................................... 12-12
12.5.1 How to Use View Accessors for Validation Against View Objects ........................ 12-12
12.5.2 How to Validate Conditions Related to All Entities of a Given Type .................... 12-13
12.5.3 What You May Need to Know About Row Set Access with View Accessors ........ 12-14
12.6 Accessing Related Entity Rows Using Association Accessors ...................................... 12-15
12.6.1 How to Access Related Entity Rows ...................................................................... 12-15
12.6.2 How to Access Related Entity Row Sets ............................................................... 12-15
12.7 Referencing Information About the Authenticated User ............................................. 12-16
12.8 Accessing Original Attribute Values ............................................................................ 12-16
12.9 Storing Information About the Current User Session .................................................. 12-17
12.9.1 How to Store Information About the Current User Session .................................. 12-17
12.9.2 How to Use Groovy to Access Information About the Current User Session ........ 12-18
12.10 Accessing the Current Date and Time .......................................................................... 12-18
12.11 Sending Notifications Upon a Successful Commit
....................................................... 12-18
12.12 Conditionally Preventing an Entity Row from Being Removed ................................... 12-19
12.13 Determining Conditional Updatability for Attributes .................................................. 12-19
12.14 Implementing Custom Validation Rules ...................................................................... 12-20
12.14.1 How to Create a Custom Validation Rule .............................................................. 12-20
12.14.2 Adding a Design Time Bean Customizer for Your Rule ........................................ 12-22
12.14.3 How to Register and Using a Custom Rule in JDeveloper ..................................... 12-23
12.14.3.1 Registering a Custom Validator at the Project Level ....................................... 12-23
12.14.3.2 Registering a Custom Validator at the IDE Level ............................................ 12-23
13 Implementing Business Services with Application Modules
13.1 About Application Modules ........................................................................................... 13-1