java - HQL Join with three tables -


i'm having issues hql since i'm newbie it. though don't have issues "simple queries", stuck query between 3 tables.

i read tutorials, can't find valid example needs. best explain problem:

i have 3 different tables, let's name them houses, owners, , ownerinfos.

given town id, need list houses town, including name , surname of house's owner.

i made simple graph show connections between tables:

enter image description here

i'm unsure on join strategy should use. kind of highly appreciated, since solving priority me.

thanks in advance!

it template

class house {      @manytoone(fetch = fetchtype.lazy)     @joincolumn(name = "fk_town")     private town town;      @onetomany(mappedby = "house")     private list<owner> owners;  }  class owner {      @manytoone(fetch = fetchtype.lazy)     @joincolumn(name = "fk_house")     private house house;      @onetoone     @joincolumn(name = "fk_owner_info")     private ownerinfo ownerinfo;  }  class ownerinfo {      @onetoone(mappedby = "ownerinfo", fetch = fetchtype.lazy)     private owner owner;  } 

the simplest case fetch owners owner info

from house h inner join fetch h.owners h.town.id = :townid 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -