如何在嵌入式类中使用映射?

时间:2018-12-24 06:20:51

标签: database hibernate spring-data-jpa embeddable

我有一个可嵌入的类,我想使用其变量之一定义映射。 请帮助我如何进行。预先感谢...

My Code --->>>

student.java

@Entity
public class Student 
{
    @Id
    @Column(name="SID")
    private int sid;
..........................

studentExtension.java

@Entity
@Table(name="STUDENTEXTENSION")
public class StudentExtension 
{
    @EmbeddedId
    private StudentExtensionEmbedded embed = new StudentExtensionEmbedded();
...................................

StudentExtensionEmbedded.java

@Embeddable
public class StudentExtensionEmbedded implements Serializable
{
    private int side;

    @OneToOne(cascade=CascadeType.ALL)
    @JoinColumn(name="SID")
    private Student student;
.........................................

在这里,我想在学生变量上的StudentExtensionEmbedded类中定义映射。

0 个答案:

没有答案