Ryan
Ryan

Reputation: 989

SQL Query in Grails to fetch all data from two tables which are in Foreign key relations

I completely new to Grails framework so I faced one problem from last 4 days onward, Actually my requirement is I have two tables 1. Stock Table. 2. Warehouse Table.

I am fetching Stock table records including Warehouse table.

There is a foreign key relation between two tables. (warehouse_id====>present in Stock Table). [My Grails class==>links][1]

And I want all the column records from both the tables in a single list with the help of SQL/HQL/Criteria/ or Native SQL.

I tried multiple times but I am getting only Stock table records but not Warehouse table records. Stock table structure

Thanks in Advance.

Upvotes: 2

Views: 598

Answers (1)

z.eljayyo
z.eljayyo

Reputation: 1289

There are many ways to go about it, but i suggest trying out Grails Criteria Projections, here is a similar issue solution:

Grails Criteria projections on joined table

Upvotes: 1

Related Questions