Join without association in HQL

后端 未结 4 569
时光说笑
时光说笑 2020-12-08 06:31

Lets say I have two tables(A, B) like:

A {id, a, c}
B {id, b, c}

I have also their entities. I want to write an HQL so that the result set

4条回答
  •  萌比男神i
    2020-12-08 07:33

    if both the table are related to each other via foreign key then you can try this:

    let:

    A {id(primary key), a, c} B {id(foreign key), b, c}

    define a variable of type parent(A) with setter and getter in B class's pojo.after that you can write query in this way. let it 'AA'

    select tbl_b.a,tbl_a.a,tbl_b.b,tbl_a.b,tbl_b.c,tbl_a.c from B tbl_b inner join tbl_b.AA tbl_b
    

提交回复
热议问题