Values return to the client in a proxy object should be converted to the proper type.

This commit is contained in:
Greg Burd 2017-08-16 13:43:46 -04:00
parent 007b6a51ae
commit 602e3521b4
2 changed files with 10 additions and 2 deletions

View file

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>net.helenus</groupId>
<artifactId>helenus-core</artifactId>
<version>2.0.19-SNAPSHOT</version>
<version>2.0.20-SNAPSHOT</version>
<packaging>jar</packaging>
<name>helenus</name>

View file

@ -34,6 +34,7 @@ import net.helenus.support.HelenusException;
import net.helenus.support.HelenusMappingException;
import java.util.*;
import java.util.function.Function;
public final class InsertOperation<T> extends AbstractOperation<T, InsertOperation<T>> {
@ -153,7 +154,14 @@ public final class InsertOperation<T> extends AbstractOperation<T, InsertOperati
// Then, fill in all the rest of the properties.
for (HelenusProperty prop : properties) {
String key = prop.getPropertyName();
if (!backingMap.containsKey(key)) {
if (backingMap.containsKey(key)) {
// Some values man need to be converted (e.g. from String to Enum). This is done
// within the BeanColumnValueProvider below.
Optional<Function<Object, Object>> converter = prop.getReadConverter(sessionOps.getSessionRepository());
if (converter.isPresent()) {
backingMap.put(key, converter.get().apply(backingMap.get(key)));
}
} else {
// If we started this operation with an instance of this type, use values from that.
if (pojo != null) {
backingMap.put(key, BeanColumnValueProvider.INSTANCE.getColumnValue(pojo, -1, prop));