2012-09-21 18 views
0

我annotaion這樣的:左加入引發Hibernate註解

@ManyToOne(optional = true, fetch = FetchType.LAZY) 
@JoinColumn(name = "ACK_BY", referencedColumnName = "USER_ID", nullable = true) 
public User ackBy; 

當我想通過用戶名來過濾主表它生成的SQL查詢是這樣的:

from ALARMS alarm0_ cross join USER user1_ where alarm0_.ACK_BY=user1_.USER_ID and (user1_.key not like 'value' or user1_.key is null) 

怎麼說休眠,我想要使用左加入像這樣:

ALARMS alarm0_ left join USER user1_ on alarm0_.ACK_BY=user1_.USER_ID (user1_.key not like 'value' or user1_.key is null) 

UPD:我不能使用HQL來解決這個問題。

+1

使用左連接? http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html_single/#queryhql-joins。你目前的HQL查詢是什麼? –

+0

我無法爲此使用HQL – Divers

+0

那麼您如何生成上述請求?你的數據庫是什麼? –

回答

0

所以看起來像它不可能扔註釋。你應該使用HQL來處理這種情況。