我有两个实体如下:JPA地图非id字段为外键
@Entity
public class Entity1
{
@Id
Long id;
@Basic
@OneToOne
@Column(unique=true,nullable=false)
String awesome;
...
}
and
@Entity
public class Entity2
{
@Id
Long id;
@OneToOne(mappedBy="awesome",targetEntity=Entity1.class)
@Column(name="myAwesome", insertable=false,updateable=false)
@Basic
String awesome; //FK to Entity1
}
我期待生成SQL,看起来像这样:
Alter Table Entity1 Add Constraint Entity1Entity2_Awesome Foreign Key (myAwesome) References Entity1.Awesome
目前没有SQL是被生成,我使用eclipselink。