Entity
@Table(name = "oldusers")
public class User implements UserDetails {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
......
@OneToMany(fetch = FetchType.LAZY, mappedBy = "userId", cascade = CascadeType.ALL)
List<User> usertList= new ArrayList<>(0);
public List<User> getUserList() {
return userList;
}
和
@Table(name = "user")
public class Usert implements Serializable {
int userId;
int position;
String name;
List<Exercise> list = new ArrayList<>(0);
OldsUser userId;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "parentid")
public OldUser getUserId() {
return this.userId;
}
}
我需要獲得通過idOldUser.For所有的用戶,我已經寫了下面的代碼
Criteria criteria = session.createCriteria(User.class);
criteria.add(Restrictions.eq("parentid", idOldUser));
但沒有得到:(
錯誤org.hibernate.QueryException:無法解析屬性:parentid:ap.entity.User – Sergei
你有兩個類「User」和「Usert」,其中「OldsUser」或者它到底是什麼? – Omoro
兩個班。頂部是OlsUser,底部是用戶 – Sergei