PROBLEM SOLVED - IGNORE. Turned out to be that someone had changed the pgm_id value.
I have the following SQL: "INSERT INTO pgm_cat (pgm_id, category_id) OUTPUT Inserted.pgm_cat_id AS pgm_cat_id VALUES(3,3) "
In Spring JDBC using getJdbcTemplate().queryForLong(sql) it throws the exception:
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The INSERT statement conflicted with the FOREIGN KEY constraint "PROGRAM_PGM_CAT_fk". The conflict occurred in database "IDP", table "dbo.PROGRAM", column 'PGM_ID'.
The strange thing is that the Foreign Key has been there all the time, this kind of functionality works with JPA/Hibernate, and the exact query listed works perfectly in MSSMA (no FK error).
Can someone explain why and how to fix it or work around it?