0 Replies - 267 Views - Last Post: 06 December 2017 - 12:16 AM

#1 llwins  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 27-September 17

JPA entity multiple table relationship

Posted 06 December 2017 - 12:16 AM

I have a data access control table to define a user can access which transaction data, let say the table structure is something like below:
Table name: userDataAccess
Columns: userID (Text), brandID (numeric, FK of Brand table), supplierID (numeric, FK of supplier table), categoryID (numeric, FK of category table)
Sample data:
userID | brandID | supplierID | categoryID
u001 | 1123 | 102 | 2
u001 | 1123 | 102 | 3
u001 | 1002 | 111 | 2
u002 | 1001 | 101 | 1
u002 | 1002 | 101 | 1

Transaction tables, are breakdown to header and detail:
Table name: trxHeader
Columns: id (numeric), createdBy (text), createdOn (timestamp), documentNo (text), supplierID (numeric, FK of supplier table), remarks (Text)

Table name: trxDetail
Columns: id (numeric), trxHeaderID (numeric, FK to trxHeader), brandID (numeric, FK of Brand table), categoryID (numeric, FK of Category table), itemCode (text), unitPrice (decimal), quantity (integer)

Now the question is how can I create a JPA entity for the userDataAccess which allow me to get the trxDetail filter with the dataAccess columns (or join with brandID, supplierID, categoryID), which the brandID and categoryID can direct join with trxDetail, but supplierID is in trxHeader?

*I already have entities for trxHeader and trxDetail


Thanks a lot!

Is This A Good Question/Topic? 0
  • +

Page 1 of 1