Best approach for Java/Maven/JPA/Hibernate build with multiple database vendor support?

Posted by HDave on Stack Overflow See other posts from Stack Overflow or by HDave
Published on 2010-05-14T05:25:46Z Indexed on 2010/05/14 5:34 UTC
Read the original article Hit count: 263

Filed under:
|
|
|
|

I have an enterprise application that uses a single database, but the application needs to support mysql, oracle, and sql*server as installation options. To try to remain portable we are using JPA annotations with Hibernate as the implementation. We also have a test-bed instance of each database running for development.

The app is building nicely in Maven, and I've played around with the hibernate3-maven-plugin and can auto-generate DDL for a given database dialect.

What is the best way to approach this so that individual developers can easily test against all three databases and our Hudson based CI server can build things propertly.

More specifically:

1) I thought the hbm2ddl goal in the hibernate3-maven-plugin would just generate a schema file, but apparently it connects to a live database and attempts to create the schema. Is there a way to have this just create the schema file for each database dialect without connecting to a database?

2) If the hibernate3-maven-plug insists on actually creating the database schema, is there a way to have it drop the database and recreate it before creating the schema?

3) I am thinking that each developer (and the hudson build machine) should have their own separate database on each database server. Is this typical?

4) Will developers have to run Maven three times...once for each database vendor? If so, how do I merge the results on the build machine?

5) There is a hbm2doc goal within hibernate3-maven-plugin. It seems overkill to run this three times...I gotta believe it'd be nearly identical for each database.

© Stack Overflow or respective owner

Related posts about jpa

Related posts about hibernate