简体   繁体   中英

JPA Annotated Entities that Reference JDBC Persisted, non-JPA Entities

I have a new project that will be utilizing JPA, and potentially Hibernate or spring-data as the provider. However, some of the persisted entities in this new project will be referencing persisted entities managed by other projects, through vanilla JDBC. These older projects can not be updated to utilize JPA at this point in time. What is the correct way to handle this? Can I not reference the non-JPA entities directly?

Theoretically, you can manage them directly within your application by creating JPA entities for them and utilizing JPA to persist them as required (from your application), while the old JDBC applications happily manage the objects in the same manner but without the benefit of JPA.

However - one caveat, if any cacheing is in place and the entities are being modifed outside of your application container - you're going to end up in dangerous territory.

I would recommend turning off local cacheing - since you'll end up with stale data whenever the JDBC application writes to database.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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