Home > Blockchain >  Running Hibernate in clustered mode
Running Hibernate in clustered mode

Time:09-17

I am planning to use Spring Data JPA along with Spring Boot with MySQL server. What are the challenges, considerations and best practices when considering running multiple instances of Spring Boot applications connecting to the DB.

As I understand from my knowledge, Hibernate should be considered when it completely owns the DB which is good in case of building monolith applications, but in case of running multiple instances (Microservices), how will each instance manage, update the state. Please guide me.

CodePudding user response:

Hibernate can be used for Microservices when there is no local state maintained in any of the service in the application. The state could be using a hibernate second-level cache. When you want to go for a second-level cache make sure it is centralized and available for all the services in the application.

In fact this is a shared database pattern and using this pattern in Microservices architecture is absolutely fine. This is discussed in Microservices architecture patterns https://microservices.io/patterns/data/shared-database.html

CodePudding user response:

Hibernate is a JPA implementation and Spring Data JPA is a JPA Data Access Abstraction. Hibernate provides a reference implementation of the Java Persistence API that makes it a great choice as an ORM tool with benefits of loose coupling...

things not change in Spring Data JPA compared Hibernate. Spring Data JPA have own method for simple Crud operation using JpaRepository but you can fire query for complex operation in relational database(mysql,postgresql,azure...etc) and jpa own databse JPQL...

  • Related