Merge pull request #14 from Timshel/master

Correction not to fail with an IllegalArgumentException when using find on an object with an enum as id.
This commit is contained in:
Rob Bygrave
2013-04-15 04:42:13 -07:00
4 changed files with 84 additions and 3 deletions
@@ -163,7 +163,9 @@ public final class IdBinderSimple implements IdBinder {
}
public void bindId(DataBind dataBind, Object value) throws SQLException {
value = idProperty.toBeanType(value);
if( !value.getClass().equals(expectedType) ){
value = scalarType.toBeanType(value);
}
idProperty.bind(dataBind, value);
}
@@ -68,7 +68,7 @@ public abstract class EnumToDbValueMap<T> {
public Iterator<Object> beanValues() {
return valueMap.values().iterator();
}
/**
* Bind using the correct database type.
*/
@@ -111,7 +111,7 @@ public abstract class EnumToDbValueMap<T> {
}
T dbValue = keyMap.get(beanValue);
if (dbValue == null && !allowNulls) {
String msg = "DB value for " + beanValue + " not found in " + valueMap;
String msg = "DB value for " + beanValue + " not found in " + keyMap;
throw new IllegalArgumentException(msg);
}
return dbValue;