Skip to content

Commit 594edf4

Browse files
Add bidirectional type mapping
1 parent ab91428 commit 594edf4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/main/java/org/javawebstack/orm/mapper/DefaultMapper.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ public Object mapToSQL(Object source, Class<?> type) {
3737
return source.toString();
3838
if (type.equals(Timestamp.class))
3939
return ((Timestamp) source).toString();
40+
if (type.equals(char.class))
41+
return String.valueOf((char) source);
42+
4043
return source;
4144
}
4245

@@ -63,6 +66,13 @@ public Object mapToJava(Object source, Class<?> type) {
6366
return ((Float) source).floatValue();
6467
if (type.equals(char[].class))
6568
return ((String) source).toCharArray();
69+
if (type.equals(char.class)) {
70+
String stringSource = String.valueOf((char) source);
71+
if (stringSource.length() != 1)
72+
return ' ';
73+
else
74+
return stringSource.charAt(0);
75+
}
6676
return source;
6777
}
6878

0 commit comments

Comments
 (0)