1
用戶相同的查詢將給出不同的輸出在MSSQL和Hibernate 3個
- 用戶ID
- 的userName
- 密碼
- 狀態
問題
- IssueNum
- issueDescription
- 狀態
- creationdate
IssueAssigned
- issueNumber
- issueAssignedTo
- issueAssignedBy
- 評論
在我primefaces的DataTable我使用下面的查詢
SELECT I.issue_number, I.issue_describtion, U.first_name,US.first_name
FROM ISSUES I
LEFT JOIN ISSUE_ASSIGNED IA
ON I.issue_number = IA.Issue_number
LEFT JOIN USERS U
ON U.id = IA.assigned_to_user_id
LEFT JOIN USERS US
ON US.id = IA.assigned_by_user_id
誰也是一個用戶管理員分配問題給其他用戶
在MSSQL中獲取這些值這上面的查詢工作正常給我適當的記錄U.firstName和US.FirstName,因爲他們是不同的用戶。
查詢在MSSQL返回
PER-1675 Perform - Evaluation Form Export does not pull any data in Legacy Export Tool (Due 8/14) Ameh Sandip
PER-2048 Calculation of scores fails when the lower/upper bound value of a calculation text result is a Ameh Sandip
但在Hibernate中,爲了同一個查詢都firstName和US.firstName給出相同的結果
代碼
@Override
public List<Object> getIssueListForAssigingIssue(){
List<Object> allIssueList = getHibernateTemplate()
.getSessionFactory()
.getCurrentSession().createSQLQuery("SELECT I.issue_number, I.issue_describtion, IT.issue_type,U.first_name ,US.first_name "
+ "FROM ISSUES I "
+ "LEFT JOIN ISSUE_ASSIGNED IA "
+ "ON I.issue_number = IA.Issue_number "
+ "LEFT JOIN USERS U "
+ "ON U.id = IA.assigned_to_user_id "
+ "LEFT JOIN USERS US "
+ "ON US.id = IA.assigned_by_user_id ").list();
return allIssueList;
}
在Hibernate查詢返回
PER-1675 Perform - Evaluation Form Export does not pull any data in Legacy Export Tool (Due 8/14) Ameh Ameh
PER-2048 Calculation of scores fails when the lower/upper bound value of a calculation text result is a Ameh Ameh
之間的混淆來解決它是那些返回的只有兩排?結果集可能相同,但順序不同。 –
這只是一個例子,實際上只有一個管理員分配問題。 – Suyash
Hibernate查詢使用JOIN。直接的SQL使用LEFT JOIN。 – gbn