Getting my webapp to be database agnostic with Hibernate...

Posted by JellyHead on Stack Overflow See other posts from Stack Overflow or by JellyHead
Published on 2010-03-09T10:26:22Z Indexed on 2010/05/02 17:18 UTC
Read the original article Hit count: 228

Filed under:
|

So the ultimate in scope-creep came in the other day: since we're using Hibernate, could we make our webapp run on Oracle as well as MySQL, interchangably?

I thought this would be a simple case of changing hibernate.cfg.xml so that instead of explicity stating MySQL-specific options, it would reference a JNDI datasource, allowing the application to build regardless of the database we intend to deploy to. Then changing to a different database would simply mean changing the separate datasource configuration in JBoss, Jetty, WebLogic etc. Is this realistic?

Well, I got as far as setting that up in Jetty, but What's tripping me up right now is error about the hibernate.dialect not having been set in hibernate.cfg.xml. But If I set the dialect there, then my app is still going to be built in either MySQL or Oracle flavours, which is not really what I want.

Either I'm trying to attempt the impossible or I've missed something fundamentally obvious... anyone else had a similar problem (and subsequent solution/workaround)?

© Stack Overflow or respective owner

Related posts about hibernate

Related posts about orm