I'm doing a school project in architecture client-server with JavaFX, Maven, Hibernate etc I have big problem with implementation alone Hibernate (without Spring). Im not sure that is problem with configuration, dependencies or MySQL :\/
<?xml version = "1.0" encoding = "utf-8"?> <!DOCTYPE hibernate-configuration SYSTEM
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/carrental</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password"></property>
<property name="connection.pool_size">10</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="current_session_context_class">thread</property>
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="hbm2ddl.auto">update</property>
<!-- List of mapping files -->
<mapping class="model.User" />
</session-factory> </hibernate-configuration>
Refer to this line in stacktrace:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'type=MyISAM' at line
This suggests that you are using an updated version of MySQL but using and old dialect.
Change
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
to
<property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>
Your current dialect
generates following
type=MyISAM
where it need to be changed to
ENGINE=MyISAM
in the create table query by Hibernate.
To acheive this you need to use different dialects
. Because MySQLDialect
is old although you use an updated version of MySQL
.
Use either,
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
OR
<property name="hibernate.dialect">org.hibernate.dialect.MySQL8Dialect</property>
in the hibernate.cfg.xml
file.
Now you can go ahead with the create query without any dialect
errors .
Can you add annotation on Id property and try Of
@GeneratedValue(strategy = GenerationType.IDENTITY)
And let the DateBase manage the incrementation of the primary key:
AUTO_INCREMENT PRIMARY KEY
Hope this helps!
I faced the same problem in Spring Boot Application.
I was using XAMP.
I fixed the issue by changing the Hibernate Dialect in application.properties
From
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
To
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
就我而言,我不小心将“desc”放在列名中,并面临同样的问题。
I faced the error "Error executing DDL "create table hibernate_sequence (next_val bigint) type=MyISAM" via JDBC Statement"
I changed org.hibernate.dialect.MySQLDialect to org.hibernate.dialect.MySQL5Dialect and it worked
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.