java


Hibernate persist same object, same table in multiple databases


We are in the process of migrating database from one DB to another and we can not afford downtime for the application. So we want to write the same entity during this process and once we migrate, we can remove the source. We are using hibernate for the application. Is there any way that hibernate can write the same entity in multiple schemas with same table structure ? . Also it should be transactional across these two DBs
You need to create 2 Sessions, each Session with one DB Connection, then when you save a bean you call the session.save() from both Sessions.
Example:
Foo foo = new Foo();
foo.setName('FooName');
foo.setType('FooType');
session1.save(foo);
session2.save(foo);
You can wrap it in a Service so you can treat with a #Transactional and avoid saving in one DB and not on the other.
If you are familiar with persistence unit then it will work great for you. You can work with multiple data-sources (i mean, database connections) defining persistence unit. See the documentation of spring persistence unit and persistence context.
I hope it will help you what you trying to achieve.

Related Links

How to implement add method from List interface
Create a BIND Clause Programmatically in Jena
getInputStream() Source code
the result of ECB Encryption is maybe different. it is same as the result of CBC
Synchronizing Async' actions (Java/android)
How To Decrypt PGP Encrypted File (Encrypted by two PGP keys. Key1 having public, private key. Key2 having only in public key) Through JAVA API
four connect ai Alpha beta minmax
java - using methods to add two numbers
error: [[“c154ab40-1aaf-11e7-92ae-000c298f510d”, “3044c8f0-1ab0-11e7-92ae-000c298f510d”]]
camel-cxfrs configuration not working
Exception in Scanner Input
Parsing error using net.sf.tweety.lp.asp.solver.Clingo
Calling a method to return a different int from a switch
Using standalone methods for each scene in JavaFX
JavaFx 8 WebView - html page screenshot
Trimming blank sound in wav file with Java

Categories

HOME
cakephp
ibm-bluemix
magnific-popup
google-api-php-client
layout
vmware
google-docs
razor
spring-cloud-stream
v8
sql-server-2016
ezpublish
mouse
kibana-4
windows-10-universal
communication
alignment
dtrace
decimal
dynamics-crm-online
clearcase-ucm
django-simple-history
angular-ui
propel
scichart
java-3d
bootstrap-tour
firebase-crash-reporting
emgucv
javacv
facet
selectedindexchanged
phpfox
jaxb2
flink-streaming
instant-messaging
google-sites-2016
asset-pipeline
openoffice.org
azure-sql-database
language-concepts
ghost4j
hexo
ios5
vxworks
xcode-extension
retina-display
starteam
objectlistview
sharefile
angularjs-factory
temporary-files
ncalc
grid.mvc
core-plot
glew
node-gyp
spring-security-kerberos
rails-routing
gabor-filter
jxcore
composite-key
sqlclient
nodebb
android-cursor
webdriverjs
spring-android
heidisql
log4c
xml-attribute
impresspages
angstrom-linux
react-native-listview
prettytensor
bluemix-app-scan
hsv
intel-fortran
cyclomatic-complexity
qdialog
muse
sframe
event-bubbling
operation
nsight
sortedlist
dundas
proj4js
inmobi
truevault
xc16
codeigniter-url
relocation
document-classification
zend-route
php-5.4
valueconverter
poller
java.nio.file
stxxl
openlaszlo
mcts
aqtime
listings
dotnetnuke-5
sqlperformance
objective-c-2.0
online-compilation
windows-phone-7.1.1
work-stealing
rfc1123
krl
jmock
xfbml
w3wp.exe
google-friend-connect
getresponsestream
nsviewanimation
mirah
private-members
multiple-languages

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App