hibernate多对多注解示例
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hibernate多对多注解示例相关的知识,希望对你有一定的参考价值。
@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多对多注解示例的主要内容,如果未能解决你的问题,请参考以下文章