In JPA and Spring, can I create a save unit on the fly?

Therefore, apparently, we need to create stability units on the fly. Basically, we have this web service and many identical schemes with the same domain classes. We want to be able to pass the request to the web service where the context path matches the schema. The first time a service is requested, then pass that schema name and create a persistence block on the fly, and then use it every time after that, and repeat the process every time a service request is made for a schema that has not yet been created .

Is it possible, using Spring and JPA, the entire building that must be completed at startup for normal PU creation? Is this brilliant idea scalable?

+3
source share
1 answer

So, if your database schemas are predefined, I don’t quite understand why you want to create continuity units on the fly.

The only example - and quite far-fetched - I can think about where this one can make sense if the number of circuits is quite large, and you do not expect that all of them will be necessary during your service. Even then, all you save is some memory.

, - (, , , , , " " ), . EntityManagerFactory, .

+2

Source: https://habr.com/ru/post/1720210/


All Articles