我很冬眠。我有两个表具有一对多的关系。两张表是:
public class Pashmina implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO, generator = "sq_pashmina_id")
@SequenceGenerator(name = "sq_pashmina_id", sequenceName = "sq_pashmina_id")
@Column(name = "PASHMINA_ID")
private int pashminaId;
@Column(name = "PASHMINA_NAME")
private String pashminaName;
@Column(name = "PRICE")
private double price;
@Column(name = "ADDED_AT", insertable = false)
@Temporal(TemporalType.TIMESTAMP)
private Date addedAt;
@Column(name = "CATEGORY")
private String category;
@Column(name = "ENABLED", insertable = false)
private Character enabled;
@OneToMany(mappedBy = "colourId", fetch = FetchType.EAGER)
private Set<PashminaColour> pashminaColor = new HashSet<PashminaColour>();
@OneToMany(mappedBy = "imageId", fetch = FetchType.EAGER)
private Set<Image> images = new HashSet<Image>();
@OneToMany(mappedBy = "descriptionId", fetch = FetchType.EAGER)
private Set<Description> descriptions = new HashSet<Description>();
//getter and setter method
这是一个父类,它与Image表具有一对多关系
public class Image implements Serializable {
@Id
@Column(name = "IMAGE_ID")
private int imageId;
@Column(name = "IMAGE_NAME")
private String imageName;
@JoinColumn(name = "PASHMINA_ID", referencedColumnName = "PASHMINA_ID")
@ManyToOne
private Pashmina pashmina;
现在,我要使用其父类的ID(即pashminaId)imagenames从Image类中选择一个
例如:
从TBL_IMAGE中选择IMAGE_NAME,其中PASHMINA_ID ='some_digit';
我如何在图像类中传递pashminaId,因为没有pashminaId它只有Parent类的Object创建Pashmina。
那么,我该如何在休眠状态下实现呢?
哈士奇WWW
相关分类