0

I am using Spring Boot 2.2.4 and hibernate 5.3.1. I am seeing the following error being thrown by

could not execute statement; SQL [n/a]; 
constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: 
could not execute statement at 

I am able to catch the exception. How do I see the SQL and parameters that caused the exception ? I see I can log all sql and parameters as shown here: How can I log SQL statements in Spring Boot?

But I would specifically like to see the ones causing the exception, and not all.

user1689987
  • 1,002
  • 1
  • 8
  • 23
  • If you can catch the exception, try constructing the query outside the try block, and you'll have access to it inside your catch block. Posting the code in question will help drive better answers. – lane.maxwell Mar 06 '23 at 21:57

0 Answers0