2014-02-24 3 views
0

난 그냥 초보자 오전,이 쿼리를 실행하고 싶습니다 어떻게 모르겠다 .. 어떤 도움주세요?내 동면 최대 절전 모드

SELECT DISTINCT agents.username 
    FROM users u 
     INNER JOIN UserDistributors ud 
        ON u.id = ud.[user] 
     INNER JOIN users agents 
        ON agents.type =9 
     INNER JOIN UserDistributors agentsdistributor 
        ON agentsdistributor.distributor = ud.distributor 
        AND agents.id=agentsdistributor.[user] 
WHERE u.id=1778 

내 user.hbm 파일이 유통 많은 관계로 하나를 가지고

<set name="userDistributors" table="UserDistributors" 
     inverse="true" lazy="true" fetch="select"> 
    <key> 
     <column name="[user]" not-null="true" /> 
      </key> 
      <one-to-many class="net.tedata.dp.model.UserDistributors" /> 
     </set> 

답변

1

Criteria c = session.createCriteria(User.class); 

c.createAlias("ud", "UserDistributors"); // inner join by default 
c.add(Restrictions.eq("ud.id", "<Name>")); 
시도