Best Hibernate primary key Generation Type when using multiple databases and Liquidbase

Viewed 73

I have an application using Hibernate for persistence and I'm using Liquibase to handle model version migrations.

My application needs to support a variety of databases (Oracle, DB2, MS Sql, MySql, and not a must, but H2 as well). Is there a best practice for handling the primary key generation type in this case where I need to support multiple databases?

I came across this article which suggests:

@GeneratedValue(strategy = GenerationType.AUTO, generator = "native")
@GenericGenerator(name = "native", strategy = "native")

Is this the correct way, or are there any other best practices for Hibernate/Liquidbase in general with multiple db implementations?

1 Answers

You can go through this document, that explains how you can add a primary key using liquibase.

Related