DetachedCriteria 关联查询出错,求解答? 400 报错 @Entity
@Table(name="t_applicant")
public class Applicant extends BaseEntity{
@Id
@Column(name="id",nullable=false)
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
@Column(name="user_id")
private User user;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@ManyToOne(cascade={CascadeType.ALL})
@JoinColumn(name="id")
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
@Entity
@Table(name="t_user")
public class User extends BaseEntity{
private static final long serialVersionUID = -7962088110132926545L;
@Id
@Column(name = "id", nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "userName")
@NotBlank(message = "用户名称不能为空.")
private String userName;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
DetachedCriteria dc = DetachedCriteria.forClass(Applicant.class);
dc.createAlias("User", "u",DetachedCriteria.LEFT_JOIN);
dc.add(Restrictions.eq("u.id", 1));
return dc;
报错:could not resolve property: User of: com.sun.entity.Applicant,求解答,感激不尽。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。