@@ -41,6 +41,24 @@ protected void mapBoolean(String columnName, Func2<TEntity, Boolean> propertyGet
4141 addColumn (columnName , Types .BIT , propertyGetter );
4242 }
4343
44+ // region Text Functions
45+
46+ protected void mapChar (String columnName , Func2 <TEntity , Character > propertyGetter ) {
47+ addColumn (columnName , Types .CHAR , propertyGetter );
48+ }
49+
50+ protected void mapVarchar (String columnName , Func2 <TEntity , String > propertyGetter ) {
51+ addColumn (columnName , Types .VARCHAR , propertyGetter );
52+ }
53+
54+ protected void mapNvarchar (String columnName , Func2 <TEntity , String > propertyGetter ) {
55+ addColumn (columnName , Types .NVARCHAR , propertyGetter );
56+ }
57+
58+ // endregion
59+
60+ // region Numeric Functions
61+
4462 protected void mapNumeric (String columnName , int precision , int scale , Func2 <TEntity , BigDecimal > propertyGetter ) {
4563
4664 // We need to scale the incoming decimal, before writing it to SQL Server:
@@ -54,6 +72,7 @@ protected void mapNumeric(String columnName, int precision, int scale, Func2<TEn
5472 return result ;
5573 };
5674
75+
5776 addColumn (columnName , Types .NUMERIC , precision , scale , false , wrapper );
5877 }
5978
@@ -94,6 +113,30 @@ protected void mapBigIntLong(String columnName, Func2<TEntity, Long> propertyGet
94113 addColumn (columnName , Types .BIGINT , isAutoIncrement , propertyGetter );
95114 }
96115
116+ protected void mapDouble (String columnName , Func2 <TEntity , Double > propertyGetter )
117+ {
118+ addColumn (columnName , Types .DOUBLE , propertyGetter );
119+ }
120+
121+ protected void mapInt (String columnName , Func2 <TEntity , Integer > propertyGetter , boolean isAutoIncrement )
122+ {
123+ addColumn (columnName , Types .INTEGER , isAutoIncrement , propertyGetter );
124+ }
125+
126+ protected void mapSmallInt (String columnName , Func2 <TEntity , Short > propertyGetter , boolean isAutoIncrement )
127+ {
128+ addColumn (columnName , Types .SMALLINT , isAutoIncrement , propertyGetter );
129+ }
130+
131+ protected void mapTinyInt (String columnName , Func2 <TEntity , Byte > propertyGetter )
132+ {
133+ addColumn (columnName , Types .TINYINT , propertyGetter );
134+ }
135+
136+ // endregion
137+
138+ // region Time Functions
139+
97140 protected void mapDate (String columnName , Func2 <TEntity , LocalDate > propertyGetter ) {
98141 addColumn (columnName , Types .DATE , propertyGetter );
99142 }
@@ -134,6 +177,7 @@ protected void mapLocalDateTime(String columnName, Func2<TEntity, LocalDateTime>
134177 }
135178
136179 protected void mapUTCNano (String dateColumnName , String timeColumnName , Func2 <TEntity , Long > propertyGetter ) {
180+
137181 // We need to scale the incoming LocalDateTime and cast it to Timestamp so that the scaling sticks, before writing it to SQL Server:
138182 final Func2 <TEntity , Date > dateWrapper = entity -> {
139183 Long result = propertyGetter .invoke (entity );
@@ -143,6 +187,7 @@ protected void mapUTCNano(String dateColumnName, String timeColumnName, Func2<TE
143187 AbstractMap .Entry <Long ,Integer > convertedDT = convertUTCNanoToEpochSecAndNano (result );
144188 return new Date (convertedDT .getKey ()*1000 );
145189 };
190+
146191 final Func2 <TEntity , String > timeWrapper = entity -> {
147192 Long result = propertyGetter .invoke (entity );
148193 if (result == null ) {
@@ -182,26 +227,6 @@ private static AbstractMap.Entry<Long,Integer> convertUTCNanoToEpochSecAndNano(L
182227 return new AbstractMap .SimpleEntry <>(epochSeconds , nanoseconds );
183228 }
184229
185- protected void mapDouble (String columnName , Func2 <TEntity , Double > propertyGetter )
186- {
187- addColumn (columnName , Types .DOUBLE , propertyGetter );
188- }
189-
190- protected void mapInt (String columnName , Func2 <TEntity , Integer > propertyGetter , boolean isAutoIncrement )
191- {
192- addColumn (columnName , Types .INTEGER , isAutoIncrement , propertyGetter );
193- }
194-
195- protected void mapSmallInt (String columnName , Func2 <TEntity , Short > propertyGetter , boolean isAutoIncrement )
196- {
197- addColumn (columnName , Types .SMALLINT , isAutoIncrement , propertyGetter );
198- }
199-
200- protected void mapTinyInt (String columnName , Func2 <TEntity , Byte > propertyGetter )
201- {
202- addColumn (columnName , Types .TINYINT , propertyGetter );
203- }
204-
205230 protected void mapTimeWithTimeZone (String columnName , Func2 <TEntity , OffsetTime > propertyGetter ) {
206231 addColumn (columnName , 2013 , propertyGetter );
207232 }
@@ -210,20 +235,17 @@ protected void mapDateTimeWithTimeZone(String columnName, Func2<TEntity, OffsetD
210235 addColumn (columnName , 2014 , propertyGetter );
211236 }
212237
213- protected void mapString (String columnName , Func2 <TEntity , String > propertyGetter ) {
214- addColumn (columnName , Types .NVARCHAR , propertyGetter );
215- }
238+ // endregion
239+
216240
217241 protected void mapVarBinary (String columnName , int maxLength , Func2 <TEntity , byte []> propertyGetter ) {
218242 addColumn (columnName , Types .VARBINARY , maxLength , 0 , false , propertyGetter );
219243 }
220244
221245 private <TProperty > void addColumn (String name , int type , boolean isAutoIncrement , Func2 <TEntity , TProperty > propertyGetter )
222246 {
223- // Create the current Column Meta Data:
224247 ColumnMetaData columnMetaData = new ColumnMetaData (name , type , 0 , 0 , isAutoIncrement );
225248
226- // Add a new Column with the Meta Data and Property Getter:
227249 addColumn (columnMetaData , propertyGetter );
228250 }
229251
@@ -242,7 +264,6 @@ private <TProperty> void addColumn(String name, int type, int precision, int sca
242264 ColumnMetaData columnMetaData = new ColumnMetaData (name , type , precision , scale , isAutoIncrement );
243265
244266 // Add a new Column with the Meta Data and Property Getter:
245-
246267 addColumn (columnMetaData , propertyGetter );
247268 }
248269
0 commit comments