|
12 | 12 | import org.postgresql.util.PGInterval; |
13 | 13 |
|
14 | 14 | import java.math.BigDecimal; |
| 15 | +import java.math.BigInteger; |
15 | 16 | import java.net.Inet4Address; |
16 | 17 | import java.net.Inet6Address; |
17 | 18 | import java.net.UnknownHostException; |
@@ -46,6 +47,7 @@ private static class SampleEntity { |
46 | 47 | public List<Double> col_double_array; |
47 | 48 | public String col_jsonb; |
48 | 49 | public BigDecimal col_numeric; |
| 50 | + public BigInteger col_bignumeric; |
49 | 51 | public Interval col_interval; |
50 | 52 |
|
51 | 53 | public Interval get_col_interval() { |
@@ -124,6 +126,10 @@ public BigDecimal getCol_numeric() { |
124 | 126 | return col_numeric; |
125 | 127 | } |
126 | 128 |
|
| 129 | + public BigInteger getCol_bignumeric() { |
| 130 | + return col_bignumeric; |
| 131 | + } |
| 132 | + |
127 | 133 | } |
128 | 134 |
|
129 | 135 | @Override |
@@ -159,6 +165,7 @@ public SampleEntityMapping() { |
159 | 165 | mapDoubleArray("col_double_array", SampleEntity::getCol_double_array); |
160 | 166 | mapJsonb("col_jsonb", SampleEntity::getCol_jsonb); |
161 | 167 | mapNumeric("col_numeric", SampleEntity::getCol_numeric); |
| 168 | + mapNumeric("col_bignumeric", SampleEntity::getCol_bignumeric); |
162 | 169 | mapInterval("col_interval", SampleEntity::get_col_interval); |
163 | 170 | } |
164 | 171 | } |
@@ -251,6 +258,32 @@ public void saveAll_numeric_Test() throws SQLException { |
251 | 258 | } |
252 | 259 | } |
253 | 260 |
|
| 261 | + |
| 262 | + @Test |
| 263 | + public void saveAll_BigNumeric_Test() throws SQLException { |
| 264 | + |
| 265 | + // This list will be inserted. |
| 266 | + List<SampleEntity> entities = new ArrayList<>(); |
| 267 | + |
| 268 | + // Create the Entity to insert: |
| 269 | + SampleEntity entity = new SampleEntity(); |
| 270 | + entity.col_bignumeric = new BigInteger("999999999999999999999999999999999999"); |
| 271 | + |
| 272 | + entities.add(entity); |
| 273 | + |
| 274 | + PgBulkInsert<SampleEntity> pgBulkInsert = new PgBulkInsert<>(new SampleEntityMapping()); |
| 275 | + |
| 276 | + pgBulkInsert.saveAll(PostgreSqlUtils.getPGConnection(connection), entities.stream()); |
| 277 | + |
| 278 | + ResultSet rs = getAll(); |
| 279 | + |
| 280 | + while (rs.next()) { |
| 281 | + BigDecimal v = rs.getBigDecimal("col_bignumeric"); |
| 282 | + |
| 283 | + Assert.assertEquals(new BigInteger("999999999999999999999999999999999999"), v.toBigInteger()); |
| 284 | + } |
| 285 | + } |
| 286 | + |
254 | 287 | @Test |
255 | 288 | public void saveAll_boolean_Test() throws SQLException { |
256 | 289 |
|
@@ -645,7 +678,7 @@ public void saveAll_ByteArray_Test() throws SQLException { |
645 | 678 | byte byte1 = 1; |
646 | 679 | byte byte2 = 2; |
647 | 680 |
|
648 | | - entity.col_bytearray = new byte[]{ byte1, byte2 }; |
| 681 | + entity.col_bytearray = new byte[]{byte1, byte2}; |
649 | 682 |
|
650 | 683 | entities.add(entity); |
651 | 684 |
|
@@ -786,7 +819,8 @@ private boolean createTable() throws SQLException { |
786 | 819 | " col_int_array integer[], \n" + |
787 | 820 | " col_double_array double precision[], \n" + |
788 | 821 | " col_jsonb jsonb, \n" + |
789 | | - " col_numeric numeric(50, 20) \n" + |
| 822 | + " col_numeric numeric(50, 20), \n" + |
| 823 | + " col_bignumeric numeric(38) \n" + |
790 | 824 | " );"; |
791 | 825 |
|
792 | 826 | Statement statement = connection.createStatement(); |
|
0 commit comments