日期:2014-05-18 浏览次数:20696 次
@Entity
@Table(name = "t_user")
public class Users implements Serializable {
@Id
private String user_code = "";// 用户工号
@Column(name = "USER_NAME")
private String user_name = "";// 用户名称
}
@Entity
@Table(name = "t_post")
public class Post implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "POST_ID")
private String postId;//岗位id
@Column(name = "POST_NAME")
private String postName;//岗位名称
}
@Entity
@Table(name = "t_user_post")
public class UserPost implements Serializable {
private static final long serialVersionUID = 1L;
@OneToOne
@JoinColumn(name = "USER_CODE")
private Users user;
@OneToOne
@JoinColumn(name = "POST_ID")
private Post post;
}
@Id
@ManyToOne
@JoinColumn(name = "USER_CODE")
private Users user;
@Id
@ManyToOne
@JoinColumn(name = "POST_ID")
private Post post;
改成这样就可以了。。。