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