0

在 Hibernate 配置文件中,我创建了一个属性

 <property name="hbm2ddl.auto">create</property>. 

当我运行项目时,出现这样的错误

ERROR: HHH000389: Unsuccessful: create table MADHU.DBTEST9_14_2013 (STUDENTIDPK number(22,0) not null unique, STUDENTDEPTNN varchar2(20 char) not null, STUDENTNAMENN varchar2(20 char) not null, primary key (STUDENTIDPK))

Sep 16, 2013 3:16:47 PM org.hibernate.tool.hbm2ddl.SchemaExport perform
ERROR: ORA-02261: such unique or primary key already exists in the table .

这是 Hibernate 自动生成的查询。我想知道为什么 Hibernate 会生成这种类型的查询并且无法执行它。

我打开 sqlplus 命令提示符并将查询更改为

MADHU.DBTEST9_14_2013 (STUDENTIDPK number(22,0), STUDENTDEPTNN varchar2(20 char) not null, STUDENTNAMENN varchar2(20 char) not null, primary key (STUDENTIDPK))

此查询完美运行。

我使用了基于注释的映射

    @Id
@Column(name = "STUDENTIDPK")
public BigDecimal getStudentidpk() {
    return this.studentidpk;
}


@Column(name = "STUDENTNAMENN", nullable = false, length = 20)
public String getStudentnamenn() {
    return this.studentnamenn;
}


@Column(name = "STUDENTDEPTNN", nullable = false, length = 20)
public String getStudentdeptnn() {
    return this.studentdeptnn;
}
4

0 回答 0