Skip to content
Advertisement

Join tables in spring data jpa

I have an issue in joining two tables column. I have two entities Status Report and Employee. and I want the data of employee inside StatusReport.

JavaScript

Another class is the employee:

JavaScript

As you can see employee entity itself have some other joins on other tables. Which is a deparment table.

JavaScript

When I join Status Report with Employee I get Sql exception. But strangly when I remove join of Department in Employee entity table then I get the result.

Can someone please help if I am missing anything?

Advertisement

Answer

Well taking help from above post. I made few other changes in my code. As I could not manage to remove the field completely from my entity class so I made it Transient and set its property from the join column object method. So my class are as follows.

Employee class is as follows.

JavaScript

StatusReport class is as follows.

JavaScript

Please also note for example while you are saving a StatusReport object by using save method of jpa you will have to set the EMPID through getEmployee().getEMPID()

Advertisement