Connect two or more applications to the same database using Hibernate Connect two or more applications to the same database using Hibernate mysql mysql

Connect two or more applications to the same database using Hibernate


You can have multiple hibernate-based apps talking to the same database. For the most part, this is pretty much the same as running multiple threads talking to the same database.

The most common problem you are likely to see will occur if your hibernate configuration is using a second-level cache. When hibernate is configured with a second-level cache, it assumes that the cache is consistent with the underlying database. When you have a single application attaching to the database, the second-level cache can exist in the local RAM of the app server and everything is good.

If you have multiple servers (whether they are running the same application or different ones), you need to have a single second-level cache that is shared by all of the servers. Or you need to not use a second-level cache.

Several distributed cache solutions for hibernate's second-level cache are available - google will help you research your various options if you decide to go this route.

Same argument applies to query cache as well.