8
8
import java .time .LocalDate ;
9
9
import java .time .LocalDateTime ;
10
10
import java .time .LocalTime ;
11
+ import java .time .OffsetDateTime ;
11
12
import java .time .temporal .ChronoUnit ;
12
13
13
14
import org .hibernate .cfg .MappingSettings ;
17
18
import org .hibernate .dialect .Dialect ;
18
19
import org .hibernate .dialect .HANADialect ;
19
20
import org .hibernate .dialect .OracleDialect ;
21
+ import org .hibernate .dialect .PostgreSQLDialect ;
20
22
import org .hibernate .dialect .SybaseDialect ;
21
23
import org .hibernate .mapping .BasicValue ;
22
24
import org .hibernate .mapping .PersistentClass ;
29
31
30
32
import org .hibernate .testing .orm .junit .DomainModel ;
31
33
import org .hibernate .testing .orm .junit .DomainModelScope ;
34
+ import org .hibernate .testing .orm .junit .RequiresDialect ;
32
35
import org .hibernate .testing .orm .junit .ServiceRegistry ;
33
36
import org .hibernate .testing .orm .junit .SessionFactory ;
34
37
import org .hibernate .testing .orm .junit .SessionFactoryScope ;
@@ -203,6 +206,23 @@ void testLocalTime(SessionFactoryScope scope) {
203
206
} );
204
207
}
205
208
209
+ @ Test
210
+ @ RequiresDialect (value = PostgreSQLDialect .class )
211
+ void testArray (SessionFactoryScope scope ) {
212
+ final var offsetDateTime = OffsetDateTime .parse ("1977-07-24T12:34:56+02:00" );
213
+ scope .inTransaction ( session -> {
214
+ final var nativeQuery = session .createNativeQuery (
215
+ "WITH data AS (SELECT unnest(?) AS id, unnest(?) AS offset_date_time)"
216
+ + " INSERT INTO EntityWithJavaTimeValues (id, theOffsetDateTime) SELECT * FROM data"
217
+ );
218
+ nativeQuery .setParameter ( 1 , new int [] { 1 } );
219
+ nativeQuery .setParameter ( 2 , new OffsetDateTime [] { offsetDateTime } );
220
+ assertThat ( nativeQuery .executeUpdate () ).isEqualTo ( 1 );
221
+ final var found = session .find ( EntityWithJavaTimeValues .class , 1 );
222
+ assertThat ( found .theOffsetDateTime .toInstant () ).isEqualTo ( offsetDateTime .toInstant () );
223
+ } );
224
+ }
225
+
206
226
@ AfterEach
207
227
void dropTestData (SessionFactoryScope scope ) {
208
228
scope .getSessionFactory ().getSchemaManager ().truncate ();
@@ -215,6 +235,8 @@ public static class EntityWithJavaTimeValues {
215
235
private Integer id ;
216
236
private String name ;
217
237
238
+ private OffsetDateTime theOffsetDateTime ;
239
+
218
240
private Instant theInstant ;
219
241
220
242
private LocalDateTime theLocalDateTime ;
0 commit comments