M
M
mitaichik2018-05-19 23:22:48
Spring
mitaichik, 2018-05-19 23:22:48

Spring: Is there an EntityManager for MongoDB?

Hello! I don’t quite understand whether it is possible to work in Spring with MongoDb using JPA?
The main goal why I want to use EntityManager is that the application has only one instance for a specific entity (as I understand it, if you use repositories from spring data mongodb, then with each selection it will create a new instance).
Is it possible to set up an EntityManager for mongo, well, or are there other ways to solve my problem?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2018-05-20
@mitaichik

First of all, I want to note that Spring Data is just a JPA add-on that automatically generates repositories. Under the hood is the same EntityManager. Which, by the way, on each selection of the same record from the database returns a new object.
In essence, the question: JPA is an object - relational mapping standard, and MongoDB is not a relational DBMS. That is, JPA is not needed. The only point in using it with MongoDB is to develop a generic data access layer that makes it easy to change the DBMS on the fly. And Spring Data is the best fit for such tasks.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question