File tree Expand file tree Collapse file tree
main/java/de/bytefish/pgbulkinsert/pgsql/model/interval
test/java/de/bytefish/pgbulkinsert/test/pgsql/handlers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ public class Interval {
66 private final int days ;
77 private final long time ;
88
9-
109 public Interval (int months , int days , long time ) {
1110 this .months = months ;
1211 this .days = days ;
Original file line number Diff line number Diff line change @@ -158,6 +158,34 @@ public SampleEntityMapping() {
158158 mapDoubleArray ("col_double_array" , SampleEntity ::getCol_double_array );
159159 mapJsonb ("col_jsonb" , SampleEntity ::getCol_jsonb );
160160 mapNumeric ("col_numeric" , SampleEntity ::getCol_numeric );
161+ mapInterval ("col_interval" , SampleEntity ::get_col_interval );
162+ }
163+ }
164+
165+ @ Test
166+ public void saveAll_interval_Test () throws SQLException {
167+
168+ // This list will be inserted.
169+ List <SampleEntity > entities = new ArrayList <>();
170+
171+ // Create the Entity to insert:
172+ SampleEntity entity = new SampleEntity ();
173+
174+ // 2 mons 15 days 02:03:04.005
175+ entity .col_interval = new Interval (2 , 15 , 7384005000L );
176+
177+ entities .add (entity );
178+
179+ PgBulkInsert <SampleEntity > pgBulkInsert = new PgBulkInsert <>(new SampleEntityMapping ());
180+
181+ pgBulkInsert .saveAll (PostgreSqlUtils .getPGConnection (connection ), entities .stream ());
182+
183+ ResultSet rs = getAll ();
184+
185+ while (rs .next ()) {
186+ Object v = rs .getObject ("col_interval" );
187+
188+ Assert .assertEquals ("2 mons 15 days 02:03:04.005" , v );
161189 }
162190 }
163191
You can’t perform that action at this time.
0 commit comments