Hello i am new to spring boot if you could help me out it would be really appreciated!!!
Consider i have following tables
buses routes bus_routes driver driver_routes busstop busstop_routes
buses and routes has a connection table bus_routes with additional columns bus_routes structure id bus_id route_id created updated is_active
As my knowlege using @ManytoMany is not possible because it has additional columns other than bus_id and route_id
from the solutions i found up online i used joins following way
Bus.java
@OneToMany(mappedBy = "bus", cascade = CascadeType.ALL)
private List<BusRoutes> busRoutes;
BusRoutes.java
@Id
@ManyToOne
@JoinColumn
private Bus bus;
@Id
@ManyToOne
@JoinColumn
private Route route;
Routes.java //As routes has connection with other three table
@OneToMany(mappedBy = "route", cascade = CascadeType.ALL)
private List<BusRoutes> busRoutes;
@OneToMany(mappedBy = "route", cascade = CascadeType.ALL,fetch = FetchType.EAGER)
private List<DriverRoutes> driverRoutes;
@OneToMany(mappedBy = "route", cascade = CascadeType.ALL,fetch = FetchType.EAGER)
private List<RouteBusStops> routeStops;
so when i try to execute multiple bag exception,any ideas how to solve this?? also can i fetch just contents of route yables without any bags??,is it possible?? What is the most efficient method for many to many with extra columns???