Skip to content
Advertisement

Unable to fetch Parent data from Child

I’m trying to see whether a Cab is assigned to any Employee so I can fetch that Employee Id and simply to set cab as null, but @OneToMany mapping, simply returning a list of Employees & by this I’m not getting any method like a cab.getEmp() to fetch employee details

Employee.java

JavaScript

Cab.java

JavaScript

Controller

JavaScript

Advertisement

Answer

In your code, Cab is perent class and Employee is child class and your goal is to remove the child class dependency with parent class. For that, You have to extract the Employee from Cab and remove the relationship with Cab using employee.setCab(null).

JavaScript
Advertisement