-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Hibernate usage with MSSQL Server and MySQL
PostPosted: Mon Dec 11, 2017 10:35 am 
Newbie

Joined: Tue Nov 28, 2017 9:42 am
Posts: 5
Hi, I have a question regarding the usage of Hibernate with different databases (MSSQL Server and MySQL) in the same application:

I started with Hibernate in Netbeans 8.2 and created a hibernate config for my MSSQL Server database, hibernate reverse-engineering file and let netbeans created the Hibernate Mapping files and POJOs from database.

Now I would like to use also a Mysql datbase with the same table-names, etc...

I tried just to change the

hibernate.connection.driver_class
hibernate.connection.url
hibernate.dialect

- properties and use the same mappings as already created for MSSQL, but this obviously does not work. I observed that e.g. in MSSQL a 'schema' has a different meaning as in Mysql.

Is there a way to use the same POJOs and mapping files for different databases? I thought that that's one of the reasons to use hibernate...

Or do I have to generate POJOs and hbm.xml - files for the different databases and instantiate them in my application depending on which db to use e.g. via factory pattern?

Regards

Klaus


Top
 Profile  
 
 Post subject: Re: Hibernate usage with MSSQL Server and MySQL
PostPosted: Mon Dec 11, 2017 12:54 pm 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Sure thing. You can have the entities as annotated for SQL Server, and provide an orm.xml which overrides annotations for the troubling mappings.

Read this article for more details.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.