码迷,mamicode.com
首页 > Web开发 > 详细

hibernate多对多注解示例

时间:2017-04-28 13:36:59      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:public   hiberna   uid   log   UI   join   version   table   generated   

@Entity
@Table(name = "photoGroup")
public class PhotoGroup implements Serializable{

private static final long serialVersionUID = -142542213293758421L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "photoGroupId")
private int photoGroupId;


@ManyToMany(mappedBy="photoGroup",fetch = FetchType.EAGER) //
private Set<Photo> photo;

}

 

@Entity
@Table(name = "photo")
public class Photo implements Serializable {
private static final long serialVersionUID = -73267813341118015L;

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "photoid")
private int photoid;

@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "photo_photoGroup", joinColumns = @JoinColumn(name = "photoid"), inverseJoinColumns = @JoinColumn(name = "photoGroupId"))
private Set<PhotoGroup> photoGroup;

}

 

参考博客:http://blog.csdn.net/jikak1153/article/details/43865701

hibernate多对多注解示例

标签:public   hiberna   uid   log   UI   join   version   table   generated   

原文地址:http://www.cnblogs.com/bigot-Lee/p/6781057.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!