Support H2database 2.x

This commit is contained in:
Rob Bygrave committed 2022-01-25 21:28:09 +13:00
1 parent 8d29a3a575
commit a9dbc036e9
12 files changed
+30 -13

No files matched your search

@@ -10,6 +10,7 @@ final class H2DbExpression extends BasicDbExpression {
@Override
public void bitwise(SpiExpressionRequest request, String propName, BitwiseOp operator, long flags, String compare, long match) {
bitwiseFunction(request, propName, operator, compare);
String funcName = functionName(operator);
request.append(funcName).append("(").append(propName).append(", cast(? as long)) ").append(compare).append(" cast(? as long)");
}
}
@@ -34,6 +34,14 @@ final class EnumToDbIntegerMap extends EnumToDbValueMap<Integer> {
addInternal(beanValue, dbValue, name);
}
@Override
public Object getBeanValue(Object dbValue) {
if (dbValue instanceof String) {
return super.getBeanValue(Integer.parseInt(dbValue.toString()));
}
return super.getBeanValue(dbValue);
}
@Override
public EnumToDbIntegerMap add(Object beanValue, String stringDbValue, String name) {
try {
@@ -116,7 +116,8 @@ abstract class EnumToDbValueMap<T> {
/**
* Return the Bean value given the DB value.
*/
public Object getBeanValue(T dbValue) {
@SuppressWarnings("SuspiciousMethodCalls")
public Object getBeanValue(Object dbValue) {
if (dbValue == null) {
return null;
}
@@ -125,8 +126,7 @@ abstract class EnumToDbValueMap<T> {
beanValue = nameMap.get(dbValue);
}
if (beanValue == null && !allowNulls) {
String msg = "Bean value for " + dbValue + " not found in " + valueMap;
throw new IllegalArgumentException(msg);
throw new IllegalArgumentException("Bean value for " + dbValue + " not found in " + valueMap);
}
return beanValue;
}