Overview:
I have Service Task (Java Delegate), which calls my custom Spring Service, which has Spring Annotated Transaction with Propogation.REQUIRED. (See EmpDetailService.java)
Scenario 1: After completing "Emp Details 1" task control goes to "Emp Details 1 Service(Java Delegates)" service task which calls custom DB service to persist data into custom tables.
now while I throw exception explicitly in service task than "Emp Details 1" task don't complete (not data insert, update, and delete in Activiti tables) and no data gets persisted in my custom tables which is expected behaviour.
Scenario 2: After completing "Emp Details 1" task control goes to "Emp Details 1 Service(Java Delegates)" service task which calls custom DB service to persist data into custom tables. In this scenario I am explicitly setting null (NOT NULL in DATABASE ) value in custom table, So while inserting/updating a record Hibernate throws exception (org.hibernate.exception.ConstraintViolationException: Column 'FIRST_NAME' cannot be null) , but surprisingly this time "Emp Details 1" task gets completed and no data gets persisted in custom tables.
So, in nutshell difference between both the scenarios is that in Scenario 1 I am throwing exception explicitly and in Scenario 2 I get exception from underlying Persistence layer.
Question:
I am unable to understand that why in Scenario 2 task gets completed even though exception is being thrown by hibernate in "Emp Details 1 Service"
I have also attached error_log.txt and my activiti configuration file and spring service class.