0

After setting up Hikari to our Grails Application (as described here ), I had to find out by observation that the hibernate behavior changed suddenly when using onAfterSave in a Gorm Domain Object:

    org.springframework.dao.DataIntegrityViolationException: Hibernate operation: could not execute statement; SQL [n/a]; ERROR: insert or update on table "xxx" violates foreign key constraint "FK_9rkehgw2fq54vy4o8yw6xqd1u"
  Detail: Key (attribution_id)=(1013967) is not present in table "attribution".; nested exception is org.postgresql.util.PSQLException: ERROR: insert or update on table "xxx" violates foreign key constraint "FK_9rkehgw2fq54vy4o8yw6xqd1u"

where (as you can see) the referenced object has an id (1013967) so the saving transaction should be commmited and there should be no violation. Removing Hikari fixed this behavior again.

I assume this has todo with Transaction Isolation and /or autocommit settings; however why does the behavior change when the pool manager is changed from Tomcat to Hikari?

What settings are to be made to restore original Grails behavior?

Thank you

Community
  • 1
  • 1
user39950
  • 464
  • 3
  • 15
  • Did you look what is the constraint "FK_9rkehgw2fq54vy4o8yw6xqd1u"? What conditions it contains? Looks like you're trying to add something to the table 'xxx' and that not existed in the table where refer the FK. – wwarlock Nov 15 '16 at 21:50
  • Thats clear :) however, on _Hibernate_ level, the condition is satisfied (but not on _database_ level). exact same statement succeeds without Hikari. – user39950 Nov 16 '16 at 14:47

0 Answers0