Monday, October 22, 2012

Transaction Level ADF BC Entity Validation

Is not so well known, but we can defer validation execution to transaction level for ADF BC entity validators. This can be applied only to Key Exist and Method validators on Entity level and is available in both ADF 11g R1 and ADF 11g R2. It is useful, because it instructs framework to invoke such validation rule only if other validation rules were passed successfully. If validation rule invokes complex code, it may affect performance - each time to invoke it together with other validations. You could defer it for later execution, only if all other validations passed - sounds good.

Download sample application - This sample implements two validation rules - one is marked to be deferred to transaction level and second is using default setting of entity level execution. You can configure validation rule execution option in Validation Execution section:

I have set both validators to return false, this will ensure both validators to fail. Let's test if validator with deferred execution will be invoked together with default one:

In order to distinguish executed validation visually, I have set different message for deferred validation - Employees validation on transaction level:

Only one validation rule is executed - it fails and framework prevents executing additionally second rule (one which is deferred):

If we test both validation rules set with default execution setting:

Both rules are executed and reported at the same time:

No comments: