1010import java .time .LocalDate ;
1111import java .time .LocalDateTime ;
1212import java .time .LocalTime ;
13+ import java .time .OffsetDateTime ;
1314import java .time .temporal .ChronoUnit ;
1415
1516import org .hibernate .cfg .MappingSettings ;
1920import org .hibernate .dialect .Dialect ;
2021import org .hibernate .dialect .HANADialect ;
2122import org .hibernate .dialect .OracleDialect ;
23+ import org .hibernate .dialect .PostgreSQLDialect ;
2224import org .hibernate .dialect .SybaseDialect ;
2325import org .hibernate .mapping .BasicValue ;
2426import org .hibernate .mapping .PersistentClass ;
3133
3234import org .hibernate .testing .orm .junit .DomainModel ;
3335import org .hibernate .testing .orm .junit .DomainModelScope ;
36+ import org .hibernate .testing .orm .junit .RequiresDialect ;
3437import org .hibernate .testing .orm .junit .ServiceRegistry ;
3538import org .hibernate .testing .orm .junit .SessionFactory ;
3639import org .hibernate .testing .orm .junit .SessionFactoryScope ;
@@ -204,6 +207,23 @@ void testLocalTime(SessionFactoryScope scope) {
204207 } );
205208 }
206209
210+ @ Test
211+ @ RequiresDialect (value = PostgreSQLDialect .class )
212+ void testArray (SessionFactoryScope scope ) {
213+ final var offsetDateTime = OffsetDateTime .parse ("1977-07-24T12:34:56+02:00" );
214+ scope .inTransaction ( session -> {
215+ final var nativeQuery = session .createNativeQuery (
216+ "WITH data AS (SELECT unnest(?) AS id, unnest(?) AS offset_date_time)"
217+ + " INSERT INTO EntityWithJavaTimeValues (id, theOffsetDateTime) SELECT * FROM data"
218+ );
219+ nativeQuery .setParameter ( 1 , new int [] { 1 } );
220+ nativeQuery .setParameter ( 2 , new OffsetDateTime [] { offsetDateTime } );
221+ assertThat ( nativeQuery .executeUpdate () ).isEqualTo ( 1 );
222+ final var found = session .find ( EntityWithJavaTimeValues .class , 1 );
223+ assertThat ( found .theOffsetDateTime .toInstant () ).isEqualTo ( offsetDateTime .toInstant () );
224+ } );
225+ }
226+
207227 @ AfterEach
208228 void dropTestData (SessionFactoryScope scope ) {
209229 scope .inTransaction ( (session ) -> {
@@ -218,6 +238,8 @@ public static class EntityWithJavaTimeValues {
218238 private Integer id ;
219239 private String name ;
220240
241+ private OffsetDateTime theOffsetDateTime ;
242+
221243 private Instant theInstant ;
222244
223245 private LocalDateTime theLocalDateTime ;
0 commit comments