Search code examples
javamysqlspringhibernateinnodb

Different MySQL engines in Java Spring


I am using Spring framework to develop a web app and I use Hibernate to support the persistent layer. I already know that I can custom my own dialect with the codes below:

public class MySQL5Dialect extends MySQL5InnoDBDialect {

    @Override
    public String getTableTypeString() {
        return " ENGINE=InnoDB DEFAULT CHARSET=utf8";
    }
}

But this applies to all the tables. Now I have different tables with different MySQL storage engines. For example, one table uses InnoDB and the other uses MyISAM. How do I accomplish this? Thanks in advance.


Solution

  • Some questions I feel compelled to answer by backing up a step and questioning the premise.

    The premise is that you want to use different engines? The response is -- Use only InnoDB.

    Your counter is -- But isn't MyISAM faster?

    The answer is -- That's an old wives' tale. It is very likely that your application (whatever it is) will run faster with all InnoDB than with any MyISAM.