Search code examples
javajpaeclipselink

How readonly entity get persisted for the first time


if readonly entity cannot be persisted , how it is persisted for the first time. thinking in the matter lead me to three choice for the persist of readonly entity:

  1. readonly entity included in two type of mapping at which it is not readyonly in one of those type.
  2. readonly entity inserted to database without the use of jpa.
  3. legacy database

what i want to know is there any other choice? is the first choice legal at which part of users/system can insert readyonly entity (configuration for example) and the major part of users just read those entity?


Solution

  • Is the first choice legal at which part of users/system can insert readyonly entity (configuration for example) and the major part of users just read those entity?

    You can do what you need in your application, as there is no restriction on how many entities can map to the same table. You would just have to adjust your cache usage to account for changes made in one entity not being shown or picked up by other entity caches until those entities are refreshed/reloaded.i.e.you need a way to cause the other users to see your configuration changes. This holds true for different entities mapping to the same table data just as it would for multiple instances of the same JPA application though.