mirror of
https://github.com/moparisthebest/JdbcMapper
synced 2024-11-21 16:45:02 -05:00
Fix rest of Enum issues
This commit is contained in:
parent
ebccf0a0e2
commit
2580de8f42
@ -327,11 +327,7 @@ public class CompilingRowToObjectMapper<K, T> extends RowToObjectMapper<K, T> {
|
||||
return _returnTypeClass.cast(val);
|
||||
}
|
||||
*/
|
||||
// we could actually pull from first row like above and test it first and fail now, but maybe just failing during compilation is enough?
|
||||
java.append("final ").append(tType).append(" ret = (").append(tType).append(") ");
|
||||
extractColumnValueString(java, 1, typeId, _returnTypeClass.getCanonicalName());
|
||||
java.append(";\n");
|
||||
return;
|
||||
// todo: we could actually pull from first row like above and test it first, but for now we will fall-through to field mappings...
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new MapperException(e.getMessage(), e);
|
||||
|
@ -524,18 +524,20 @@ public class RowToObjectMapper<K, T> extends AbstractRowMapper<K, T> {
|
||||
+ "stripped of '_' and compared if no match is found with them.");
|
||||
}
|
||||
_fields[i] = f;
|
||||
final Class<?> type;
|
||||
if (f instanceof Field) {
|
||||
final Field field = (Field) f;
|
||||
_fields[i] = modField(field, i);
|
||||
_fieldTypes[i] = _tmf.getTypeId(field.getType());
|
||||
type = field.getType();
|
||||
} else {
|
||||
type = ((Method) f).getParameterTypes()[0];
|
||||
}
|
||||
_fieldTypes[i] = _tmf.getTypeId(type);
|
||||
if(_fieldTypes[i] == TypeMappingsFactory.TYPE_ENUM) {
|
||||
@SuppressWarnings("unchecked")
|
||||
final Class<? extends Enum> noWarnings = (Class<? extends Enum>) field.getType();
|
||||
final Class<? extends Enum> noWarnings = (Class<? extends Enum>) type;
|
||||
_fieldClasses[i] = noWarnings;
|
||||
}
|
||||
} else {
|
||||
_fieldTypes[i] = _tmf.getTypeId(((Method) f).getParameterTypes()[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,14 @@ public class EnumPerson implements Person {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setFirstName(final FirstName firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public void setLastName(final String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) return true;
|
||||
|
Loading…
Reference in New Issue
Block a user