简体   繁体   English

jpa实体在不同的应用程序上

[英]jpa entities on different applications

I have a java backend integration application (no UI) spring/jpa based. 我有一个基于spring / jpa的Java后端集成应用程序(无UI)。 now I am creating a UI web application (also spring/jpa based) to support queries on the backend application. 现在,我正在创建一个UI Web应用程序(也基于spring / jpa),以支持后端应用程序上的查询。 So I will have two applications (jvms) using the same DB. 因此,我将有两个使用同一数据库的应用程序(jvm)。 My question is - will cahanges in the DB made by the backend integration application , be reflected on the jpa entities of the UI application ? 我的问题是-后端集成应用程序在数据库中产生的变化会反映在UI应用程序的jpa实体上吗? or I have to force my entities to always go to the DB in order to be up to date ? 还是我必须强迫我的实体始终访问数据库才能保持最新状态?

There is no magical synchronisation of changes between the different JVMs. 不同的JVM之间没有神奇的更改同步。 The UI application will only see changes that have been persisted into the DB by the backend application. UI应用程序将仅看到后端应用程序已将其保留在数据库中的更改。 So, in short, yes you will need to force DB persistence/lookup for your entities. 简而言之,是的,您将需要为实体强制进行数据库持久性/查找。

Note that you may also run into caching issues (for example, Hibernate does some automatic caching of entities by default). 请注意,您还可能会遇到缓存问题(例如,默认情况下,Hibernate会对实体进行一些自动缓存)。 If the UI application has cached an entity, it will not see changes made by the backend application even if persisted into the DB, until the UI application does a new query to the DB itself as well. 如果UI应用程序已经缓存了一个实体,则即使UI应用程序也对数据库本身进行了新查询,它也不会看到后端应用程序所做的更改,即使该更改持久化到了DB中也是如此。

Therefore I would advise you to test this thoroughly and adjust your configuration as necessary. 因此,我建议您进行彻底测试,并根据需要调整配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM