88import java .time .LocalDate ;
99import java .time .LocalDateTime ;
1010import java .time .LocalTime ;
11+ import java .time .OffsetDateTime ;
1112import java .time .temporal .ChronoUnit ;
1213
1314import org .hibernate .cfg .MappingSettings ;
1718import org .hibernate .dialect .Dialect ;
1819import org .hibernate .dialect .HANADialect ;
1920import org .hibernate .dialect .OracleDialect ;
21+ import org .hibernate .dialect .PostgreSQLDialect ;
2022import org .hibernate .dialect .SybaseDialect ;
2123import org .hibernate .mapping .BasicValue ;
2224import org .hibernate .mapping .PersistentClass ;
2931
3032import org .hibernate .testing .orm .junit .DomainModel ;
3133import org .hibernate .testing .orm .junit .DomainModelScope ;
34+ import org .hibernate .testing .orm .junit .RequiresDialect ;
3235import org .hibernate .testing .orm .junit .ServiceRegistry ;
3336import org .hibernate .testing .orm .junit .SessionFactory ;
3437import org .hibernate .testing .orm .junit .SessionFactoryScope ;
@@ -203,6 +206,23 @@ void testLocalTime(SessionFactoryScope scope) {
203206 } );
204207 }
205208
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+
206226 @ AfterEach
207227 void dropTestData (SessionFactoryScope scope ) {
208228 scope .getSessionFactory ().getSchemaManager ().truncate ();
@@ -215,6 +235,8 @@ public static class EntityWithJavaTimeValues {
215235 private Integer id ;
216236 private String name ;
217237
238+ private OffsetDateTime theOffsetDateTime ;
239+
218240 private Instant theInstant ;
219241
220242 private LocalDateTime theLocalDateTime ;
0 commit comments