-1

My application was built on Grails and MySQL. We've recently switched our DB to MariaDB and I understand it's fully compliant with MySQL. I am now trying to add a new domain object in my Grails app. Table creation fails with the following error.

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=InnoDB' at line 1

Grails creates tables with TYPE=INNODB at the end of the statement. I found out that having ENGINE=InnoDB in place of TYPE=INNODB resolves the issue. I manually ran the create table SQL on DB and it worked. However, I do not know how to have Grails use ENGINE=INNODB Vs Type=INNODB.

FYI. My app uses MySQL5InnoDBDialect and the following driver.

mysql:mysql-connector-java:5.1.32

I changed it with MariaDB driver and dialect but the results are same.

Burt Beckwith
  • 75,342
  • 5
  • 143
  • 156

2 Answers2

0

According to this post your should change your dialect in org.hibernate.dialect.MariaDBDialect if Hibernate version is >= 5.2.8 or you should use MySQL5InnoDBDialect

Luca Farsetti
  • 257
  • 2
  • 14
  • I am sorry but that did not solve the problem. It seems like using the correct dialect is the solution but I can't figure out what it is. Also, I do not know if there's something else I should be looking at? – JavaProgrammer Jun 29 '17 at 17:36
  • I am using Grails Version 2.4.4. It makes total sense that changing the dialect solves the problem. Upon closer look, I found out that the source code had several datasources and not all of them were MySQL5InnoDBDialect. Some were MySQLInnoDBDialect. After all data sources were updated to MySQL5InnoDBDialect, the problem was resolved. @Luca Farsetti, Thankyou! – JavaProgrammer Jul 07 '17 at 11:16
-1

changeSet(author: "sonalpatel(generated)", id: "1309959832163-2") { createTable(tableName: "payment") { column(autoIncrement: "true", name: "id", type: "bigint") { constraints(nullable: "false", primaryKey: "true", primaryKeyName: "paymentPK") } column(name: "version", type: "bigint") { constraints(nullable: "false") }

    column(name: "buyer_id", type: "bigint") {
        constraints(nullable: "false")
    }

    column(name: "buyer_information_id", type: "bigint")

    column(name: "currency", type: "varchar(255)") {
        constraints(nullable: "false")
    }

    column(name: "discount_cart_amount", type: "decimal(19,2)") {
        constraints(nullable: "false")
    }

    column(name: "paypal_transaction_id", type: "varchar(255)")

    column(name: "status", type: "varchar(9)") {
        constraints(nullable: "false")
    }

    column(name: "tax", type: "double precision(19)") {
        constraints(nullable: "false")
    }

    column(name: "transaction_id", type: "varchar(255)")
}

}

Sona
  • 1
  • 1