Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » JPA Caching and NPE(Caching)
JPA Caching and NPE [message #1281994] Tue, 01 April 2014 18:13
Stephen Hooper is currently offline Stephen HooperFriend
Messages: 2
Registered: April 2014
Junior Member
I have the following JPA map setup using EclipseLink 2.5.1

@Entity
@Table(name = "ACCOUNTS")
public class Account extends AbstractAggregateRoot<Long> {
         ...
	private AccountMetadata metadata = new AccountMetadata();
}


@Embeddable
@Access(AccessType.PROPERTY)
public class AccountMetadata extends Metadata {

	@ElementCollection(fetch=FetchType.EAGER)
	@CollectionTable(name="ACCOUNT_METADATA",
			joinColumns=@JoinColumn(table="ACCOUNTS", referencedColumnName="ID",            name="ACCOUNT_ID"))
	@Column(name= "MD_VALUE")
	public Map<Key,String> getMetadata() {
		return this.metadata;
	}
	
	public void setMetadata(Map<Key,String> md) {
		this.metadata = md;
	}
}



@Embeddable
public class Metadata implements Serializable {

....

	protected Map<Key,String> metadata = new HashMap<>();
	
	@Embeddable
	@Access(AccessType.FIELD)
	public static class Key {
		@Enumerated(EnumType.STRING)
		@Column(name = "KEY_NS")
		private Namespace ns;
		@Column(name = "KEY_NAME")
		private String name;
	
	...
	
	}
}


When caching is enabled everything maps fine. When I disable caching by adding the following to the persistence XML

<shared-cache-mode>NONE</shared-cache-mode>


I receive the following error when attempting to commit.

Caused by: Exception [EclipseLink-69] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: A NullPointerException was thrown while extracting a value from the instance variable [ns] in the object [oracle.cloudstorage.common.domain.Metadata$Key].
Internal Exception: java.lang.NullPointerException
Mapping: org.eclipse.persistence.mappings.DirectToFieldMapping[ns-->KEY_NS]
Descriptor: RelationalDescriptor(oracle.cloudstorage.common.domain.Metadata$Key --> [])
	at org.eclipse.persistence.exceptions.DescriptorException.nullPointerWhileGettingValueThruInstanceVariableAccessor(DescriptorException.java:1277)
	at org.eclipse.persistence.internal.descriptors.InstanceVariableAttributeAccessor.getAttributeValueFromObject(InstanceVariableAttributeAccessor.java:88)
	at org.eclipse.persistence.mappings.DatabaseMapping.getAttributeValueFromObject(DatabaseMapping.java:615)
	at org.eclipse.persistence.mappings.foundation.AbstractDirectMapping.compareObjects(AbstractDirectMapping.java:407)
	at org.eclipse.persistence.mappings.foundation.AbstractDirectMapping.compareForChange(AbstractDirectMapping.java:381)
	at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.createObjectChangeSetThroughComparison(DeferredChangeDetectionPolicy.java:186)
	at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.createObjectChangeSet(DeferredChangeDetectionPolicy.java:146)
	at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.calculateChanges(DeferredChangeDetectionPolicy.java:91)
	at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.calculateChangesForExistingObject(DeferredChangeDetectionPolicy.java:56)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.calculateChanges(UnitOfWorkImpl.java:664)
	at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.writeChanges(RepeatableWriteUnitOfWork.java:438)
	at org.eclipse.persistence.internal.jpa.EntityManagerImpl.flush(EntityManagerImpl.java:863)


Has anyone else experienced this problem? I have tried different caching parameters and the only one that seems to work is enabling
cache

<shared-cache-mode>DISABLE_SELECTIVE</shared-cache-mode>


and adding this to the top of the entity

@Cache(refreshAlways=true)



Previous Topic:EclipseLink deadlock after SELECT 1 FROM DUAL
Next Topic:Selection criteria in any mapping
Goto Forum:
  


Current Time: Thu Apr 18 22:52:28 GMT 2024

Powered by FUDForum. Page generated in 0.01403 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top