#963 - NullPointerException on no version provided (when setVersion(null) is used)

This commit is contained in:
rob bygrave
2017-06-25 14:44:13 +12:00
parent 8ca3599cbf
commit 520d35b1d6
4 changed files with 48 additions and 4 deletions
@@ -29,6 +29,9 @@ public class GeneratedCounter implements GeneratedProperty {
@Override
public Object getUpdateValue(BeanProperty prop, EntityBean bean, long now) {
Number currVal = (Number) prop.getValue(bean);
if (currVal == null) {
throw new IllegalStateException("version property has been set to null on bean: " + bean);
}
Integer nextVal = currVal.intValue() + 1;
return BasicTypeConverter.convert(nextVal, numberType);
}
@@ -25,8 +25,11 @@ public class GeneratedCounterInteger implements GeneratedProperty {
*/
@Override
public Object getUpdateValue(BeanProperty prop, EntityBean bean, long now) {
Integer i = (Integer) prop.getValue(bean);
return i + 1;
Integer val = (Integer) prop.getValue(bean);
if (val == null) {
throw new IllegalStateException("version property has been set to null on bean: " + bean);
}
return val + 1;
}
/**
@@ -25,8 +25,11 @@ public class GeneratedCounterLong implements GeneratedProperty {
*/
@Override
public Object getUpdateValue(BeanProperty prop, EntityBean bean, long now) {
Long i = (Long) prop.getValue(bean);
return i + 1;
Long val = (Long) prop.getValue(bean);
if (val == null) {
throw new IllegalStateException("version property has been set to null on bean: " + bean);
}
return val + 1;
}
/**