DetachedCriteria 关联查询出错,求解答
@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;
@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;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这样用真的可以吗?