Cache Isolation Level Warning on Parent Entity

时光毁灭记忆、已成空白 提交于 2019-12-13 00:16:44

问题


After adding a second persistence unit and changing my application's data sources to XADataSource (MySQL), I'm now getting a confusing warning in the glassfish log about isolation levels on my parent entity:

WARN  o.e.p.s.f.j.ejb_or_metadata : Parent Entity BaseEntity has an isolation
level of: PROTECTED which is more protective then the subclass Contact with
isolation: null so the subclass has been set to the isolation level PROTECTED.

After some research, I think that this isolation level warning message is coming from EclipseLink's caching mechanism. But I am not specifying an isolation level anywhere in my app, so it appears that something in my configuration has triggered the BaseEntity class to have an isolation level of 'PROTECTED'. The documentation is silent on what might cause it to be automatically assigned to that level -- see user guide.

Minor testing with a single user has shown that the application seems to work as expected, but this warning message doesn't make me feel comfortable rolling it out to the masses.

Can anyone shed some light into this message? Are my concerns valid?


回答1:


The cache implementation here is just trying to sync the isolation level of parnet and child entity. But i think you should override the default protective isolation level. Because "Serializeable" isolation level is the one which is most protective and has poor performance. You can use Read Committed or Repeatable Read levels, depending upon your requirements.




回答2:


This is just a warning about cache isolation, it has nothing to due with database isolation, so you can just ignore it.

For more info on cache isolation see,

http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Caching/Shared_and_Isolated

It is odd if you have not done any caching configuration though. By default everything should be SHARED, to get something as PROTECTED you must have disabled aching for a related entity, such as using @Cacheable(false)?




回答3:


After some research, I discovered that this warning had nothing to do with using the XADataSource. I had earlier began some exploration into EclipseLink's Multitenancy, and it turned out that this was the culprit.

Referring to http://wiki.eclipse.org/EclipseLink/Examples/JPA/Multitenant#Persistence_Usage_for_Multiple_Tenants:

When using this architecture there is a shared cache available for regular entity types but the Multitenant types must be PROTECTED in the cache so the MULTITENANT_SHARED_EMF property must be set to true.

FYI -- In reviewing the code, there are 3 other cases in ClassDescriptor.initializeCaching() in which the cache isolation is downgraded to PROTECTED:

  1. If the entity has a DatabaseMapping marking it as non-cacheable.
  2. If the entity has a ForeignReferenceMapping that doesn't have an isolation level of shared.
  3. If the entity has a AggregateObjectMapping that doesn't have an isolation level of shared.


来源:https://stackoverflow.com/questions/10824508/cache-isolation-level-warning-on-parent-entity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!