2011-08-17 23 views
7

我在JBoss上部署了一個EJB項目,並帶有一些實體類。Hibernate JPA create table type = InnoDB問題

當我部署EJB的Jboss給了我這樣的例外:

create table service_db (id integer not null auto_increment, ipAddress varchar(255),  
primary key (id)) type=InnoDB 
Unsuccessful: create table service_db (id integer not null auto_increment, 
ipAddress varchar(255), primary key (id)) type=InnoDB 
2011-08-17 11:38:59,997 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 'type=InnoDB' at line 1.... 

它不應該是引擎InnoDB的=代替的類型?我試圖在沒有運氣的情況下在mysql中執行這個語句(同樣的錯誤)。如果我使用引擎移除或替換類型,它正在工作。

我的問題是,我可以改變這種情況嗎?

這是我persistance.xml(如果它是很重要的)

<?xml version="1.0" encoding="UTF-8"?> 
<persistence version="1.0" 
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"> 
<persistence-unit name="default"> 

    <jta-data-source>java:/DUMMY_DS</jta-data-source> 
    <properties> 
     <property name="hibernate.hbm2ddl.auto" value="create" /> 
     <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect" /> 
    </properties> 

</persistence-unit> 

,並在情況下,數據源的XML文件是很重要的:

<datasources> 
<local-tx-datasource> 
    <jndi-name>DUMMY_DS</jndi-name> 

    <connection-url>jdbc:mysql://localhost/cargosoft</connection-url> 
    <driver-class>com.mysql.jdbc.Driver</driver-class> 
    <user-name>hauke</user-name> 
    <password>******</password> 
    <min-pool-size>5</min-pool-size> 
    <max-pool-size>20</max-pool-size> 
    <idle-timeout-minutes>10</idle-timeout-minutes> 
    <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>  
    <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name> 
    </local-tx-datasource> 
</datasources> 

感謝您的幫助。

Hauke

+0

Duplicate:http://stackoverflow.com/questions/5231325/mysql-5-5-9-and-hibernate-table-creation-error-on-type – Vlad

回答

34

改爲使用MySQL5InnoDBDialect

+6

只是爲了方便複製和粘貼'org.hibernate。方言.MySQL5InnoDBDialect' –

+0

感謝你,我解決了。 –

+0

@deprecated改用「hibernate.dialect.storage_engine = innodb」環境變量或JVM系統屬性。 – slim