Entity Graph for nested associations of tables in Spring JPA

974 Views Asked by At

There are 3 tables in my db:

SalesOrderMaster
SalesOrderDetail
CustomerMaster

I have repository class SalesOrderDetailRespository.java which has this method findAll()

@EntityGraph(attributePaths = {"SalesOrderMaster"}, type = EntityGraph.EntityGraphType.FETCH)
List<SalesOrderInfo> findAll(@Nullable Specification<SalesOrderInfo> spec);

This is till now fetching the SalesOrderMaster record and associated SalesOrderDetails records. Now my requirement is in SalesOrderInfo class , I have added a new property for showing the Customer Information like Name , country which are there in CustomerMaster table.

The customerMaster table is related to SalesOrderMaster by customerId column. How do I add CustomerMaster table in the existing EntityGraph so that I can get this info?

0

There are 0 best solutions below