Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Best way for project to work with multiple different DB's
PostPosted: Mon Feb 27, 2017 10:40 am 
Newbie

Joined: Mon Feb 27, 2017 10:28 am
Posts: 2
I have a project which requires connecting to different RDMS which will have similar Tables/Rows/Datatype but not identical. Has anyone any experience of this? wondering the best way to map entities when the Table name/Column name and Type may differ? Should I use separate config file for each database or will that require twice the maintenance?


Top
 Profile  
 
 Post subject: Re: Best way for project to work with multiple different DB's
PostPosted: Mon Feb 27, 2017 11:00 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1534
Location: Romania
There are two very important aspects to keep in mind:

1. Always use incremental migration scripts for each particular database. Use Flyway to manage the schema version updates.
2. You can define the common mappings using annotations, and only override the database-specific mappings using orm.xml configuration files. Check out this article for more details for an example of how you can override a default SEQUENCE identifier with an IDENTITY one for MySQL.

Having a core mapping will allow you to minimize duplication, while still allowing you to diverge one DB from the other.

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
 Post subject: Re: Best way for project to work with multiple different DB's
PostPosted: Mon Feb 27, 2017 12:10 pm 
Newbie

Joined: Mon Feb 27, 2017 12:05 pm
Posts: 1
Hi vlad,

How should we setup transaction management when we need transaction across multiples databases?


Top
 Profile  
 
 Post subject: Re: Best way for project to work with multiple different DB's
PostPosted: Wed Mar 01, 2017 3:42 pm 
Newbie

Joined: Mon Feb 27, 2017 10:28 am
Posts: 2
Thanks Vlad am trying this out.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 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.