0

I have two entities Employee and Project. I am trying to create a Many-To-Many relationship between them and I succeed doing so using a junction table only with their primary keys.

I realized I would like to have other columns in that junction table so I used this tutorial to do so.

But after following the tutorial and trying to fetch all projects assigned to an employee, I am getting the following exception.

com.microsoft.sqlserver.jdbc.SQLServerException: Invalid column name 'employee_EMPLOYEE_ID_PK'.

There is no employee_EMPLOYEE_ID_PK in my code so Spring Data Jpa is concatenating the employee_ prefix.

How can I disable this behavior?

Sabin Antohe
  • 41
  • 1
  • 6

1 Answers1

0

use the mapped by attribute and join columns and inverse joins in your code that will create 3 tables otherwise if you dont do that you are going to get four tables.that is table1,table2 ,table1_table2 and table2_table1.it must be showing because of other table in which primary key is project_id. From the tutorial you have posted it doesnt seem like you have used mapped by join column and inverse joins. Or better use this site for learning javabrains.io/topics/hibernate

Nikhil S
  • 3,786
  • 4
  • 18
  • 32