0

How do I get hibernate to use InnoDB instead of MyISAM when creating my tables? The suggestions at Hibernate: Create Mysql InnoDB tables instead of MyISAM are not working for me.

I am using Glassfish 3.1.2 and MySql 5. Also I have MySQL installed through XAMPP on Mac OSX Lion.

Community
  • 1
  • 1
kasavbere
  • 5,873
  • 14
  • 49
  • 72
  • btw I have altered both my `persistence.xml` and my `hibernate.cfg.xml` to use `org.hibernate.dialect.MySQL5InnoDBDialect`. And when that failed I tried `org.hibernate.dialect.MySQLInnoDBDialect`. Nothing. – kasavbere Oct 08 '12 at 06:13
  • What about setting InnoDB as the default engine? (Highly recommended anyway) –  Oct 08 '12 at 06:33
  • @a_horse_with_no_name, I have been looking into that. It's not clear yet how to do it. I have the xampp my.cnf file open but there is no line saying `default-table-type` to comment out. – kasavbere Oct 08 '12 at 06:44
  • If it's not there, then add it. –  Oct 08 '12 at 06:47
  • Possible duplicate of this -https://stackoverflow.com/questions/1459265/hibernate-create-mysql-innodb-tables-instead-of-myisam] – Ajay Kumar Aug 02 '18 at 19:57

1 Answers1

0

After much research, I learned that setting the database default to InnoDB is not good practice. A great number of reasons is given, such as InnoDB is expensive. In light of all the reasonings, I concluded that clearly if making InnoDB default was best practice then it's likely the database would come configured as such. So I kept looking for a different solution.

Anyway, the solution was this: Go to glassfish and add the following properties to the JDBC connection pool in question.

Name: SessionVariables
Value: storage_engine=InnoDB.

This works for me like a charm. If someone has a better solution, I would really love to hear it.

kasavbere
  • 5,873
  • 14
  • 49
  • 72