我有一些hibernate @OneToMany映射的问题.就像这里一样
@Entity
@Table(name = "albums")
@SequenceGenerator(name = "ALBUMS_SEQ", sequenceName = "albums_seq", allocationSize = 1)
public class AlbumDs {
@Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ALBUMS_SEQ")
private Integer id;
private Integer ownerId;
private String name;
private String description;
private Date created;
@OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name = "albumId", insertable = true, updatable = true)
private Set<UserAlbumDs> users = new HashSet<UserAlbumDs>();
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getOwnerId() { …Run Code Online (Sandbox Code Playgroud) 我有这样的实体:
@Entity
public class Album {
private Integer id;
private Integer ownerId;
private String name;
private String description;
private Date created;
@OneToMany @JoinColumn(name = "albumId")
private Set<AlbumUser> users = new HashSet<AlbumUser>();
@OneToMany @JoinColumn(name = "albumId")
private Set<Picture> pictures = new HashSet<Picture>();
}
Run Code Online (Sandbox Code Playgroud)
另一个:
@Entity
public class Picture {
private Integer id;
private Integer creatorId;
private Integer albumId;
private Date created;
private String title;
private String description;
@ManyToOne @JoinColumn(name = "eventId")
private Event event;
}
Run Code Online (Sandbox Code Playgroud)
使用Criteria API我希望获得具有过滤的Picturs集的唯一AlbumD.我尝试这样的事情:
public Album read(Integer albumId, …Run Code Online (Sandbox Code Playgroud)