Rumah  >  Artikel  >  pangkalan data  >  Mengapa saya mendapat ralat sintaks "type=MyISAM" dalam DDL yang dijana Hibernate?

Mengapa saya mendapat ralat sintaks "type=MyISAM" dalam DDL yang dijana Hibernate?

Mary-Kate Olsen
Mary-Kate Olsenasal
2024-11-15 07:16:02303semak imbas

Why am I getting the

Invalid Syntax Error "type=MyISAM" in Hibernate-Generated DDL

In Java code, users may encounter the following syntax error:

Caused by :`com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException`: 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 1

This error arises when Hibernate generates a table creation query that includes the fragment "type = MyISAM." However, this syntax is deprecated in MySQL 4.0 and removed in 5.5.

Dialect Configuration

The problem stems from the use of the org.hibernate.dialect.MySQLDialect dialect, which is for MySQL 4.x or earlier. For MariaDB, it is recommended to use one of the following dialects, depending on the versions of MariaDB and Hibernate:

  • org.hibernate.dialect.MariaDBDialect
  • org.hibernate.dialect.MariaDB53Dialect
  • org.hibernate.dialect.MariaDB106Dialect (or higher)

For MySQL, or if the MariaDB dialects are unavailable, consider using:

  • org.hibernate.dialect.MySQL5Dialect
  • org.hibernate.dialect.MySQL55Dialect
  • org.hibernate.dialect.MySQL57Dialect
  • org.hibernate.dialect.MySQL8Dialect
  • Variants of these dialects (e.g., org.hibernate.dialect.MySQL57InnoDBDialect)

Hibernate 6 Dialects

With Hibernate 6, users should switch back to using MySQLDialect or MariaDBDialect as these dialects will configure themselves based on the actual connected version.

Atas ialah kandungan terperinci Mengapa saya mendapat ralat sintaks "type=MyISAM" dalam DDL yang dijana Hibernate?. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn