我有一个正在使用 maven 构建的项目,我需要使用 hibernate3-maven-plugin 中的 hbm2ddl 工具生成一个模式。
我需要使用一个名为Order的表(如 SQL 关键字)创建数据库,并且我不知道如何让 maven 在生成脚本时引用该表。我进行了搜索,发现休眠中有一个属性可以告诉 hbm2ddl 工具,但我不能告诉插件使用它:
<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>
非常感谢任何提示或帮助。
谢谢!