I’m using Quarkus with Panache and Hibernate 6, and MSSQL. Our Entities is using GenerationType.IDENTITY.
We need to preload the database before to start the application. At dev we are using a simple import.sql file with insert statements, but I believe this problem is going to be the same at production where we are going to use Flyway.
Our problem is that we are getting an exception as soon as we start our tests.
2024-07-30 08:15:50,608 WARN [org.hib.rea.pro.ser.ReactiveGenerationTarget] (vert.x-eventloop-thread-0) HR000021: DDL command failed [org.hibernate.exception.SQLGrammarException: error executing SQL statement [{number=544, state=1, severity=16, message='Cannot insert explicit value for identity column in table 'BUSINESS_UNITS' when IDENTITY_INSERT is set to OFF.', serverName='6de5913051ec', lineNumber=1}] [INSERT INTO BUSINESS_UNITS(id, code, desc, name) VALUES (1, 'it-po', 'IT', 'Information Technology PO')]]
[
Certainly this error is because we are adding the id in the insert statement. But how could we know the generated id in order to also do the inserts on the join tables ?