堅持我的POJO我有這樣的:與@Transient
@Transient
private int qtyMentee;
,在我的DAO我有這個疑問:
public List<Employee> findQtyMentee(){
TypedQuery<Employee> query = (TypedQuery<Employee>) em.createNativeQuery(
"select *, count(mentor_id) as qtymentee from employee group by id order by qtymentee asc" , Employee.class);
Collection<Employee> employee = (Collection<Employee>) query.getResultList();
return (List<Employee>) employee;
}
當我試圖讓Qtymentee不斷返回0
註釋@Transient
在這種情況下是錯誤的嗎?
如何獲取該值並在我的應用程序中顯示?
OBS:我正在使用Eclipselink。
謝謝。
感謝的答案,但我只需要在特定的情況這個屬性。 如果我刪除它,Eclipselink將返回此錯誤: '錯誤500:列「qtymentee」不存在。 實際上,qtymentee是一個計算列。 –