在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;
}