2011-08-17 7 views
7

Tôi có một Dự án EJB được triển khai trên JBoss với một số lớp thực thể.Hibernate JPA tạo loại bảng = InnoDB Bài toán

Ngay sau khi tôi triển khai các EJB Jboss mang lại cho tôi ngoại lệ này:

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.... 

nên không đó là động cơ = InnoDB thay vì loại? Tôi đã cố gắng để thực hiện tuyên bố này trong mysql mà không có may mắn (cùng một lỗi). Nếu tôi loại bỏ hoặc thay thế loại với động cơ nó đang làm việc.

Câu hỏi của tôi là, tôi có thể thay đổi điều đó ở đâu?

Đây là persistance.xml của tôi (trong trường hợp điều quan trọng là)

<?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> 

và trong trường hợp các tập tin nguồn dữ liệu xml là quan trọng:

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

Nhờ sự giúp đỡ của bạn.

Hauke ​​

+0

Trùng lặp: http://stackoverflow.com/questions/5231325/mysql-5-5-9-and-hibernate-table-creation-error-on-type – Vlad

Trả lời

34

Thay vào đó hãy sử dụng MySQL5InnoDBDialect.

+6

Chỉ để dễ dàng sao chép và dán 'org.hibernate. dialect.MySQL5InnoDBDialect' –

+0

Nhờ bạn, tôi đã giải quyết. –

+0

@deprecated Sử dụng "hibernate.dialect.storage_engine = innodb" biến môi trường hoặc thuộc tính hệ thống JVM thay thế. – slim