Community
Participate
Working Groups
Isolated caches in EclipseLink can be used for several things. The initial design was to enable VPD support for Oracle. As a result, the default setting makes the cache "completely isolated". This means that objects outside the isolated cache cannot reference objects inside the isolated cache. Another use for this setting is to simply avoid storing objects in the shared cache. When using isolated caches in this way, it is desirable to be able to set it on an Enity-by-entity basis and have some Entities stored in the isolated cache and some stored in the shared cache. We should add a cache setting that allows this scenario. GlassFish bug 5012 provides and example of a user that needs this functionality.
Changed version to unspecified
Updating priority due to revised bug categorization process. See the following page for details: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines#Priority_and_Target_Milestone If you feel the updated priority is incorrect, please send an email to eclipselink-users@eclipse.org.
Created attachment 161177 [details] Eclipse project with reproduction
I've renamed this bug to frame it in terms of JPA 2.0 requirements. Fixing this bug will probably resolve the bug as originally stated. EclipseLink's restrictions regarding relationships between shared cached and not shared cached (isolated) entities are applied to JPA 2.0 entities that are cacheable and not cachable. The example below with throw a validation exception. If both entities are cachable true or both false, there's no exception. It should be possible to mix Cachable(true) with Cachable(false) entities. Reproduction attached. @Entity @Cacheable(true) public class Publisher implements Serializable { @OneToOne private Address address; ... @Entity @Cacheable(false) public class Address implements Serializable { [EL Info]: property eclipselink.jdbc.user is deprecated, property javax.persistence.jdbc.user should be used instead. [EL Info]: property eclipselink.jdbc.driver is deprecated, property javax.persistence.jdbc.driver should be used instead. [EL Info]: property eclipselink.jdbc.url is deprecated, property javax.persistence.jdbc.url should be used instead. [EL Info]: property eclipselink.jdbc.password is deprecated, property javax.persistence.jdbc.password should be used instead. [EL Config]: The access type for the persistent class [class model.Address] is set to [FIELD]. [EL Config]: The access type for the persistent class [class model.Publisher] is set to [FIELD]. [EL Config]: The target entity (reference) class for the one to one mapping element [field address] is being defaulted to: class model.Address. [EL Config]: The alias name for the entity class [class model.Address] is being defaulted to: Address. [EL Config]: The table name for entity [class model.Address] is being defaulted to: ADDRESS. [EL Config]: The column name for element [field id] is being defaulted to: ID. [EL Config]: The column name for element [field country] is being defaulted to: COUNTRY. [EL Config]: The alias name for the entity class [class model.Publisher] is being defaulted to: Publisher. [EL Config]: The table name for entity [class model.Publisher] is being defaulted to: PUBLISHER. [EL Config]: The column name for element [field id] is being defaulted to: ID. [EL Config]: The column name for element [field name] is being defaulted to: NAME. [EL Config]: The primary key column name for the mapping element [field address] is being defaulted to: ID. [EL Config]: The foreign key column name for the mapping element [field address] is being defaulted to: ADDRESS_ID. [EL Info]: property eclipselink.jdbc.user is deprecated, property javax.persistence.jdbc.user should be used instead. [EL Info]: property eclipselink.jdbc.driver is deprecated, property javax.persistence.jdbc.driver should be used instead. [EL Info]: property eclipselink.jdbc.url is deprecated, property javax.persistence.jdbc.url should be used instead. [EL Info]: property eclipselink.jdbc.password is deprecated, property javax.persistence.jdbc.password should be used instead. [EL Info]: EclipseLink, version: Eclipse Persistence Services - 2.0.1.v20100213-r6600 [EL Fine]: Detected Vendor platform: org.eclipse.persistence.platform.database.JavaDBPlatform [EL Config]: Connection(23447542)--connecting(DatabaseLogin( platform=>JavaDBPlatform user name=> "app" datasource URL=> "jdbc:derby://localhost:1527/example;create=true" )) [EL Config]: Connection(19589694)--Connected: jdbc:derby://localhost:1527/example;create=true User: app Database: Apache Derby Version: 10.3.2.1 - (599110) Driver: Apache Derby Network Client JDBC Driver Version: 10.3.2.1 - (599110) [EL Config]: Connection(7912507)--connecting(DatabaseLogin( platform=>JavaDBPlatform user name=> "app" datasource URL=> "jdbc:derby://localhost:1527/example;create=true" )) [EL Config]: Connection(9296972)--Connected: jdbc:derby://localhost:1527/example;create=true User: app Database: Apache Derby Version: 10.3.2.1 - (599110) Driver: Apache Derby Network Client JDBC Driver Version: 10.3.2.1 - (599110) [EL Severe]: Local Exception Stack: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.IntegrityException Descriptor Exceptions: --------------------------------------------------------- Exception [EclipseLink-195] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.DescriptorException Exception Description: The shared class model.Publisher must not reference the isolated class model.Address. Mapping: org.eclipse.persistence.mappings.OneToOneMapping[address] Descriptor: RelationalDescriptor(model.Publisher --> [DatabaseTable(PUBLISHER)]) Exception [EclipseLink-41] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.DescriptorException Exception Description: A non-read-only mapping must be defined for the sequence number field. Descriptor: RelationalDescriptor(model.Publisher --> [DatabaseTable(PUBLISHER)]) Runtime Exceptions: --------------------------------------------------------- at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:478) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:406) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:671) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:620) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:228) at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:369) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:151) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:207) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:195) at example.Reproduction.main(Reproduction.java:12) Descriptor Exceptions: --------------------------------------------------------- Local Exception Stack: Exception [EclipseLink-195] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.DescriptorException Exception Description: The shared class model.Publisher must not reference the isolated class model.Address. Mapping: org.eclipse.persistence.mappings.OneToOneMapping[address] Descriptor: RelationalDescriptor(model.Publisher --> [DatabaseTable(PUBLISHER)]) at org.eclipse.persistence.exceptions.DescriptorException.isolateDescriptorReferencedBySharedDescriptor(DescriptorException.java:886) at org.eclipse.persistence.mappings.ForeignReferenceMapping.initializeReferenceDescriptor(ForeignReferenceMapping.java:866) at org.eclipse.persistence.mappings.ForeignReferenceMapping.initialize(ForeignReferenceMapping.java:840) at org.eclipse.persistence.mappings.OneToOneMapping.initialize(OneToOneMapping.java:964) at org.eclipse.persistence.descriptors.ClassDescriptor.initialize(ClassDescriptor.java:2634) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:449) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:406) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:671) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:620) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:228) at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:369) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:151) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:207) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:195) at example.Reproduction.main(Reproduction.java:12) Local Exception Stack: Exception [EclipseLink-41] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.DescriptorException Exception Description: A non-read-only mapping must be defined for the sequence number field. Descriptor: RelationalDescriptor(model.Publisher --> [DatabaseTable(PUBLISHER)]) at org.eclipse.persistence.exceptions.DescriptorException.mappingForSequenceNumberField(DescriptorException.java:910) at org.eclipse.persistence.internal.descriptors.ObjectBuilder.validate(ObjectBuilder.java:2833) at org.eclipse.persistence.descriptors.ClassDescriptor.selfValidationAfterInitialization(ClassDescriptor.java:3528) at org.eclipse.persistence.descriptors.ClassDescriptor.validateAfterInitialization(ClassDescriptor.java:5250) at org.eclipse.persistence.descriptors.ClassDescriptor.postInitialize(ClassDescriptor.java:3244) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:463) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:406) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:671) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:620) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:228) at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:369) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:151) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:207) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:195) at example.Reproduction.main(Reproduction.java:12) Runtime Exceptions: --------------------------------------------------------- [EL Severe]: Local Exception Stack: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.IntegrityException Descriptor Exceptions: --------------------------------------------------------- Exception [EclipseLink-195] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.DescriptorException Exception Description: The shared class model.Publisher must not reference the isolated class model.Address. Mapping: org.eclipse.persistence.mappings.OneToOneMapping[address] Descriptor: RelationalDescriptor(model.Publisher --> [DatabaseTable(PUBLISHER)]) Exception [EclipseLink-41] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.DescriptorException Exception Description: A non-read-only mapping must be defined for the sequence number field. Descriptor: RelationalDescriptor(model.Publisher --> [DatabaseTable(PUBLISHER)]) Runtime Exceptions: --------------------------------------------------------- at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:478) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:406) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:671) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:620) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:228) at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:369) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:151) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:207) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:195) at example.Reproduction.main(Reproduction.java:12) Descriptor Exceptions: --------------------------------------------------------- Local Exception Stack: Exception [EclipseLink-195] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.DescriptorException Exception Description: The shared class model.Publisher must not reference the isolated class model.Address. Mapping: org.eclipse.persistence.mappings.OneToOneMapping[address] Descriptor: RelationalDescriptor(model.Publisher --> [DatabaseTable(PUBLISHER)]) at org.eclipse.persistence.exceptions.DescriptorException.isolateDescriptorReferencedBySharedDescriptor(DescriptorException.java:886) at org.eclipse.persistence.mappings.ForeignReferenceMapping.initializeReferenceDescriptor(ForeignReferenceMapping.java:866) at org.eclipse.persistence.mappings.ForeignReferenceMapping.initialize(ForeignReferenceMapping.java:840) at org.eclipse.persistence.mappings.OneToOneMapping.initialize(OneToOneMapping.java:964) at org.eclipse.persistence.descriptors.ClassDescriptor.initialize(ClassDescriptor.java:2634) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:449) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:406) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:671) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:620) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:228) at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:369) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:151) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:207) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:195) at example.Reproduction.main(Reproduction.java:12) Local Exception Stack: Exception [EclipseLink-41] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.DescriptorException Exception Description: A non-read-only mapping must be defined for the sequence number field. Descriptor: RelationalDescriptor(model.Publisher --> [DatabaseTable(PUBLISHER)]) at org.eclipse.persistence.exceptions.DescriptorException.mappingForSequenceNumberField(DescriptorException.java:910) at org.eclipse.persistence.internal.descriptors.ObjectBuilder.validate(ObjectBuilder.java:2833) at org.eclipse.persistence.descriptors.ClassDescriptor.selfValidationAfterInitialization(ClassDescriptor.java:3528) at org.eclipse.persistence.descriptors.ClassDescriptor.validateAfterInitialization(ClassDescriptor.java:5250) at org.eclipse.persistence.descriptors.ClassDescriptor.postInitialize(ClassDescriptor.java:3244) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:463) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:406) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:671) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:620) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:228) at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:369) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:151) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:207) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:195) at example.Reproduction.main(Reproduction.java:12) Runtime Exceptions: --------------------------------------------------------- Exception in thread "main" javax.persistence.PersistenceException: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.IntegrityException Descriptor Exceptions: --------------------------------------------------------- Exception [EclipseLink-195] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.DescriptorException Exception Description: The shared class model.Publisher must not reference the isolated class model.Address. Mapping: org.eclipse.persistence.mappings.OneToOneMapping[address] Descriptor: RelationalDescriptor(model.Publisher --> [DatabaseTable(PUBLISHER)]) Exception [EclipseLink-41] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.DescriptorException Exception Description: A non-read-only mapping must be defined for the sequence number field. Descriptor: RelationalDescriptor(model.Publisher --> [DatabaseTable(PUBLISHER)]) Runtime Exceptions: --------------------------------------------------------- at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:397) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:151) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:207) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:195) at example.Reproduction.main(Reproduction.java:12) Caused by: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.IntegrityException Descriptor Exceptions: --------------------------------------------------------- Exception [EclipseLink-195] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.DescriptorException Exception Description: The shared class model.Publisher must not reference the isolated class model.Address. Mapping: org.eclipse.persistence.mappings.OneToOneMapping[address] Descriptor: RelationalDescriptor(model.Publisher --> [DatabaseTable(PUBLISHER)]) Exception [EclipseLink-41] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.DescriptorException Exception Description: A non-read-only mapping must be defined for the sequence number field. Descriptor: RelationalDescriptor(model.Publisher --> [DatabaseTable(PUBLISHER)]) Runtime Exceptions: --------------------------------------------------------- at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:478) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:406) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:671) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:620) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:228) at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:369) ... 4 more
*** Bug 205502 has been marked as a duplicate of this bug. ***
Targetting and assigning for 2.1.1. One of the first items to be addressed in 2.1.1
This issue was a bigger item than origionally thought. Being fixed in 2.2.
Created attachment 183782 [details] Intial Pre-Review patch
Hi Gordon, I have a couple of schema suggestions for you: 1. In bug 328937, Guy mentioned that the partitioning policies should not have been added to the deprecated mapping basic-map and basic-collection. The same should apply for non-cacheable. 2.The annotation is named NonCacheable so I think in the schema it should be 'non-cacheable' instead of 'noncacheable'. Either that or the annotation should be renamed to Noncacheable.
The annotation has been renamed to Noncacheable
This bug has been resolved through multiple commits. This bug was resolved through the new Cache Isolation feature.
https://fisheye2.atlassian.com/changelog/eclipselink/?cs=8803 https://fisheye2.atlassian.com/changelog/eclipselink/?cs=8804 https://fisheye2.atlassian.com/changelog/eclipselink/?cs=8826 https://fisheye2.atlassian.com/changelog/eclipselink/?cs=8827
I found a work around of this bug. I couldn't migrate to JPA 2 so i had to find an other solution. In my case, i only needed to put the Many size on cache, because this collection is not updated frequently. I couldn't use L2 cache in this collecion because of this bug (since the Many size had a reference to the One side (@ManyToOne). What i did was to remove the @ManyToOne annotation and i used a normal @Column. And i used the @JoinColumn in the @OneToMany size. I know JPA 1 is not obligated to implement Unidirectional One-to-Many association using a foreign key mapping, but seems that eclipselink 1 supports it. Hope it helps.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink