的EclipseLink生成建表所示:的EclipseLink JPA +生成ID列意外
Create Table myTable (ID (255) not null, col1 (255), col2(255), col3(255) PK (ID, col1, col2)
@Embeddable
MyPK implements Serializable
{
@OneToOne
@Id
String col1;
@OneToOne
@Id
String col2;
...
}
@Entity
MyClass implements Serializable
{
@EmbeddedId
MyPK pk;
String col1;
String col2;
String col3;
...
}
如何防止ID
列的产生在Create Table
声明?我问,因为em.persist(MyClass)
抛出一个约束例外ID
为空。我预计@EmbeddedId
将覆盖此并防止创建该字段。
编辑
我试图在代码生成表看起来像这样:
fk - col1
fk - col2
VarChar - col3
'String'外键? – 2011-04-06 15:06:06
@Matt是的,的确是我的朋友。 – user123435234234234 2011-04-06 15:09:05