开发者

Using same hbm for multiple databases

开发者 https://www.devze.com 2023-03-20 08:59 出处:网络
We are using hibernate in our project. We have have 2 databases(ORACLE and MYSQL). Currently we want to create sequences on oracle, so changes are done on

We are using hibernate in our project. We have have 2 databases(ORACLE and MYSQL). Currently we want to create sequences on oracle, so changes are done on hbm to use sequences for generator. But as same hbm is used when connected t开发者_运维问答o MYSQL and MYSQL doesn't support sequences, So Is there a way to use same hbm files for both the dbs.

Thanks in advance

Yogesh


If you want to target Oracle database, you can keep compatibility with 'auto-increment' databases such as MySQL by using the "native" id generator. This also accepts the 'sequence' parameter if you want to name a specific ORACLE sequence. This is ignored when using a database that supports 'auto-increment' columns.

    <generator class="native">
        <param name="sequence">MY_ORACLE_SEQUENCE</param>
    </generator>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号