|
10 | 10 |
|
11 | 11 | import java.math.BigDecimal; |
12 | 12 | import java.math.BigInteger; |
| 13 | +import java.math.RoundingMode; |
13 | 14 | import java.sql.Timestamp; |
14 | 15 | import java.sql.Types; |
15 | 16 | import java.time.*; |
@@ -48,17 +49,42 @@ protected void mapBoolean(String columnName, ToBooleanFunction<TEntity> property |
48 | 49 | // region Text Functions |
49 | 50 |
|
50 | 51 | protected void mapChar(String columnName, Function<TEntity, Character> propertyGetter) { |
51 | | - mapProperty(columnName, Types.CHAR, propertyGetter, new CharacterConverter()); |
| 52 | + mapProperty(columnName, Types.CHAR, propertyGetter, new TextConverter()); |
| 53 | + } |
| 54 | + |
| 55 | + protected void mapNchar(String columnName, Function<TEntity, Character> propertyGetter) { |
| 56 | + mapProperty(columnName, Types.NCHAR, propertyGetter, new TextConverter()); |
| 57 | + } |
| 58 | + |
| 59 | + protected void mapClob(String columnName, Function<TEntity, Character> propertyGetter) { |
| 60 | + mapProperty(columnName, Types.CLOB, propertyGetter, new TextConverter()); |
52 | 61 | } |
53 | 62 |
|
54 | 63 | protected void mapVarchar(String columnName, Function<TEntity, String> propertyGetter) { |
55 | 64 | mapProperty(columnName, Types.VARCHAR, propertyGetter, new VarcharConverter()); |
56 | 65 | } |
57 | 66 |
|
| 67 | + protected void mapLongVarchar(String columnName, Function<TEntity, Character> propertyGetter) { |
| 68 | + mapProperty(columnName, Types.LONGVARCHAR, propertyGetter, new TextConverter()); |
| 69 | + } |
| 70 | + |
58 | 71 | protected void mapNvarchar(String columnName, Function<TEntity, String> propertyGetter) { |
59 | 72 | mapProperty(columnName, Types.NVARCHAR, propertyGetter, new NVarcharConverter()); |
60 | 73 | } |
61 | 74 |
|
| 75 | + protected void mapLongNvarchar(String columnName, Function<TEntity, Character> propertyGetter) { |
| 76 | + mapProperty(columnName, Types.LONGNVARCHAR, propertyGetter, new TextConverter()); |
| 77 | + } |
| 78 | + |
| 79 | + |
| 80 | + // endregion |
| 81 | + |
| 82 | + // region Special Functions |
| 83 | + |
| 84 | + protected <TProperty> void mapNull(String columnName, Function<TEntity, TProperty> propertyGetter) { |
| 85 | + mapProperty(columnName, Types.NULL, propertyGetter, new NullConverter<>()); |
| 86 | + } |
| 87 | + |
62 | 88 | // endregion |
63 | 89 |
|
64 | 90 | // region Numeric Functions |
@@ -106,11 +132,14 @@ protected void mapLong(String columnName, ToLongFunction<TEntity> propertyGetter |
106 | 132 | } |
107 | 133 |
|
108 | 134 | protected void mapNumeric(String columnName, int precision, int scale, Function<TEntity, BigDecimal> propertyGetter) { |
109 | | - mapProperty(columnName, Types.NUMERIC, precision, scale, false, propertyGetter, new BigDecimalConverter(scale)); |
| 135 | + mapProperty(columnName, Types.NUMERIC, precision, scale, false, propertyGetter, new BigDecimalConverter(scale, RoundingMode.HALF_UP)); |
| 136 | + } |
| 137 | + protected void mapNumeric(String columnName, int precision, int scale, RoundingMode roundingMode, Function<TEntity, BigDecimal> propertyGetter) { |
| 138 | + mapProperty(columnName, Types.NUMERIC, precision, scale, false, propertyGetter, new BigDecimalConverter(scale, roundingMode)); |
110 | 139 | } |
111 | 140 |
|
112 | 141 | protected void mapDecimal(String columnName, int precision, int scale, Function<TEntity, BigDecimal> propertyGetter) { |
113 | | - mapProperty(columnName, Types.DECIMAL, precision, scale, false, propertyGetter, new BigDecimalConverter(scale)); |
| 142 | + mapProperty(columnName, Types.DECIMAL, precision, scale, false, propertyGetter, new BigDecimalConverter(scale, RoundingMode.HALF_UP)); |
114 | 143 | } |
115 | 144 |
|
116 | 145 | protected void mapReal(String columnName, Function<TEntity, Float> propertyGetter) { |
|
0 commit comments