Cached Map Update NPE on element remove [message #1011408] |
Tue, 19 February 2013 14:26 |
Cristian Oancea 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)
org.eclipse.persistence.internal.queries.MapContainerPolicy
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
org.eclipse.persistence.internal.queries.MappedKeyMapContainerPolicy
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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02850 seconds