Throwing ValidationException from the beforeCommit() logic !

If you have some validation logic added to beforeCommit() of the ApplicationModuleImpl or EntityObjectImpl and you face strange rollback behavior(Entity Objects are losing the modified data) while committing data second time after correcting the validation error, then this post is for you :)

From Developer's Guide....
8.5.2 How to Validate Conditions Related to All Entities of a Given Type

If your beforeCommit() logic can throw a ValidationException, you must set the jbo.txn.handleafterpostexc property to true in your configuration to have the framework automatically handle rolling back the in-memory state of the other entity objects that may have already successfully posted to the database (but not yet been committed) during the current commit cycle.

Java Option : -Djbo.txn.handleafterpostexc=true


  1. Hi Jobinesh,

    What is the benefit of using an Entity Object over doing table manipulations from back-end?

  2. Well the question here can rephrased as "Why do you need ORM tools like ADF BC/Hibernate etc"?. As this has been discussed in lot of places, I'm just copying some discussions I noticed in net

  3. Hi Jobinesh,

    I am sorry to bother you with some specific implementation. I like your posts and follow the posts regularly. I thought you can help me in resolving the issue.

    Is there any possibility of catching model validation failures in valuechangelistener code.


    I am coming from the UI. We have a requirement to call a service when the value is changed after making sure the data of the field is correct (The validation depends on some other db queries too). Once the data is validated, we have to set other attributes of the entity object. Then we have to make a service call on application module if all the validations are passed and the required attributes are set with out any problem.


    We have implemented the validations at the attribute level on the entity object and implemented setAttribute method to set other required attributes.

    We have a valuechagelistener for that field in UI and we are calling service method after calling valueChangeEvent.getComponent().processUpdates(FacesContext.getCurrentInstance()).

    But we have to prevent the service call if the validation on the model layer fails. How can I capture the error messages and prevent the service call execution.

    If I am doing some thing wrong with the implementation, can you please suggest best way to meet the requirement.

    Thanks and Regards,

    S R Prasad

  4. Prasad,
    ValueChaneEvent happens before the model update and validation. One work around is to queue the vent for later phase, something as shown below
    public void test(ValueChangeEvent valueChangeEvent) {

    if(!valueChangeEvent.getPhaseId().equals(PhaseId.INVOKE_APPLICATION) ){
    //Your business logic goes here...


Post a Comment