Can I create MyISAM and InnoDB tables in the same database using Hibenrate hbm2ddl

I need both MyISAM tables and InnoDB tables in my database, I use hbm2ddl to create them. Can I create MyISAM and InnoDB tables in the same database using Hibenrate hbm2ddl? It seems that choosing a dialect makes me use one or the other.

+3
source share
1 answer

Well, as you wrote, Hibernate will generate InnoDB tables if you use MySQL5InnoDBDialect:

public class MySQL5InnoDBDialect extends MySQL5Dialect {

    public boolean supportsCascadeDelete() {
        return true;
    }

    public String getTableTypeString() {
        return " ENGINE=InnoDB";
    }

    public boolean hasSelfReferentialForeignKeyBug() {
        return true;
    }

}

, Hibernate ENGINE=InnoDB CREATE TABLE. , .

hbm2ddl , ALTER . 5.7. . :

5.7.

CREATE DROP . , . , , SQL, java.sql.Statement.execute() (, ALTERs, INSERTS, ..). :

- CREATE DROP :

<hibernate-mapping>
    ...
    <database-object>
        <create>CREATE TRIGGER my_trigger ...</create>
        <drop>DROP TRIGGER my_trigger</drop>
    </database-object>
</hibernate-mapping>

- , CREATE DROP. org.hibernate.mapping.AuxiliaryDatabaseObject.

<hibernate-mapping>
    ...
    <database-object>
        <definition class="MyTriggerDefinition"/>
    </database-object>
</hibernate-mapping>

, , , .

<hibernate-mapping>
    ...
    <database-object>
        <definition class="MyTriggerDefinition"/>
        <dialect-scope name="org.hibernate.dialect.Oracle9iDialect"/>
        <dialect-scope name="org.hibernate.dialect.Oracle10gDialect"/>
    </database-object>
</hibernate-mapping>

: (ab) Hibernate import.sql ALTER.

+2

Source: https://habr.com/ru/post/1757529/


All Articles