Maven で構築しているプロジェクトがあり、hibernate3-maven-plugin の hbm2ddl ツールを使用してスキーマを生成する必要があります。
SQL キーワードのようなOrderというテーブルを使用してデータベースを作成する必要がありますが、スクリプトを生成するときにこのテーブルを引用するように maven を作成する方法がわかりません。検索を行ったところ、hbm2ddl ツールにこれを指示するプロパティが hibernate にあることがわかりましたが、プラグインにそれを使用するように指示することはできません。
<property name="hbm2ddl.keywords">auto-quote</property>
表を引用しない場合、hbm2ddl はスクリプトを生成します。
create table Order (orderId varchar(36) not null, orderCode integer, customer varchar(36) not null, supplier varchar(36) not null, product varchar(36) not null, forecast float, dateRaised date not null, dateDispatched date, dateReceived date, quantityOrdered double precision not null, quantitySent double precision, primary key (orderId)) ENGINE=InnoDB;
コンパイルされません (明らかな構文エラーのため):
02:51:41,264 ERROR org.hibernate.tool.hbm2ddl.SchemaExport - Unsuccessful: create table Order (orderId varchar(36) not null, orderCode integer, customer varchar(36) not null, supplier varchar(36) not null, product varchar(36) not null, forecast float, dateRaised date not null, dateDispatched date, dateReceived date, quantityOrdered double precision not null, quantitySent double precision, primary key (orderId)) ENGINE=InnoDB
02:51:41,264 ERROR org.hibernate.tool.hbm2ddl.SchemaExport - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Order (orderId varchar(36) not null, orderCode integer, customer varchar(36) not' at line 1
これは pom.xml ファイルの一部です。
<configuration>
<components>
<component>
<name>hbm2java</name>
<implementation>annotationconfiguration</implementation>
<outputDirectory>src/main/java</outputDirectory>
</component>
<component>
<name>hbm2ddl</name>
<implementation>annotationconfiguration</implementation>
<outputDirectory>src/main/resources</outputDirectory>
</component>
<component>
<name>hbm2doc</name>
<implementation>annotationconfiguration</implementation>
<outputDirectory>docs/html/hibernate</outputDirectory>
</component>
</components>
<componentProperties>
<create>true</create>
<drop>true</drop>
<configurationfile>src/main/resources/hibernate.cfg.xml</configurationfile>
<propertyfile>src/main/resources/database.properties</propertyfile>
<jdk5>true</jdk5>
<outputfilename>amasbe_db.sql</outputfilename>
</componentProperties>
</configuration>
ヒントやヘルプは本当にありがたいです。
ありがとうございました!