Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Cached Map Update NPE on element remove
Cached Map Update NPE on element remove [message #1011408] Tue, 19 February 2013 14:26 Go to next message
Cristian Oancea is currently offline Cristian OanceaFriend
Messages: 2
Registered: February 2013
Junior Member
in 2.4.0

for a 1-M relation using a map with table key , on remove the SQL transaction is commited , but cache is not , a NPE is thrown

@OneToMany(fetch = FetchType.LAZY, targetEntity = Child.class,
mappedBy = "direct", cascade = { CascadeType.REMOVE },
orphanRemoval = true)
@MapKeyColumn(name = "child_name", table = "child", insertable = false,
updatable = false)

@Cache(type = CacheType.HARD_WEAK, size = 10000, expiry = -1,
alwaysRefresh = true, isolation = CacheIsolationType.SHARED,
coordinationType = CacheCoordinationType.INVALIDATE_CHANGED_OBJECTS)
@Cacheable(value = true)


key = null
element !=null

public boolean removeFrom(Object key, Object element, Object container, AbstractSession session) {
try {
Object returnValue = null;
if (key != null) {
returnValue = ((Map)container).remove(key);
} else if (element != null) {
returnValue = ((Map)container).remove(keyFrom(element, session));
### hier comes a NullPointerException

if (returnValue == null) {
return false;
} else {
return true;
} catch (UnsupportedOperationException ex) {
throw QueryException.methodNotValid(container, "remove(Object element)");

the keyFrom function returns a null


public Object keyFrom(Object element, AbstractSession session) {
// key is mapped to the database table and not the object and therefore cannot be extracted from the object
if (keyMapping != null){
return null;
return super.keyFrom(element, session);

is there any solution ?

If I use Set it works.

[Updated on: Wed, 20 February 2013 09:16]

Report message to a moderator

Re: Cached Map Update NPE on element remove [message #1017175 is a reply to message #1011408] Sun, 10 March 2013 14:52 Go to previous messageGo to next message
Cristian Oancea is currently offline Cristian OanceaFriend
Messages: 2
Registered: February 2013
Junior Member
Caused by: java.lang.NullPointerException
at java.util.Hashtable.hash(
at java.util.Hashtable.remove(
at org.eclipse.persistence.indirection.IndirectMap.remove(
at org.eclipse.persistence.indirection.IndirectMap.remove(
at org.eclipse.persistence.internal.queries.MapContainerPolicy.removeFrom(
at org.eclipse.persistence.internal.queries.ContainerPolicy.mergeChanges(
at org.eclipse.persistence.internal.queries.ContainerPolicy.mergeChanges(
at org.eclipse.persistence.mappings.CollectionMapping.mergeChangesIntoObject(
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.mergeChangesIntoObject(
at org.eclipse.persistence.internal.sessions.MergeManager.mergeChangesOfWorkingCopyIntoOriginal(
at org.eclipse.persistence.internal.sessions.MergeManager.mergeChangesOfWorkingCopyIntoOriginal(
at org.eclipse.persistence.internal.sessions.MergeManager.mergeChanges(
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.mergeChangesIntoParent(
at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.mergeChangesIntoParent(
at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitRootUnitOfWork(
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitAndResume(
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(
... 32 more#
Re: Cached Map Update NPE on element remove [message #1021081 is a reply to message #1017175] Tue, 19 March 2013 13:54 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

This could be a bug in @MapKeyColumn, please log the bug with detailed information and test if possible.

Your model does not seem like it should be using a @MapKeyColumn though, you should just use a @MapKey as the name is contained in the Child object.
You could also not use a Map to workaround the issue.


James : Wiki : Book : Blog : Twitter
Previous Topic:IllegalArgument Exception using a Enum as Query Parameter
Next Topic:@JoinFetch doesn't work with mappings on Embeddables
Goto Forum:

Current Time: Tue Jun 19 01:14:05 GMT 2018

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

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

Back to the top