I see what you are saying, the thing is, outside of the tests, the queries 
are working perfectly as they are, and before the version updates it worked 
fine in tests as well. The fact that the problem only shows up when using 
h2 made me think that it is a h2 related problem.

On Friday, April 21, 2023 at 6:51:57 PM UTC+3 Evgenij Ryazanov wrote:

> Hello!
>
> This problem is not related to H2 at all.
>
> H2 by itself can return TIMESTAMP WITH TIME ZONE and compatible values as 
> java.time.Instant from its JDBC driver if it is explicitly requested.
>
> try (Connection c = DriverManager.getConnection("jdbc:h2:mem:")) {
>
> ResultSet rs = c.createStatement().executeQuery("VALUES TIMESTAMP WITH 
> TIME ZONE '2023-01-02 03:04:05.123456789+00'");
>
> rs.next();
>
> System.out.println(rs.getObject(1, Instant.class));
>
> }
>
> But when you use some library on top of JDBC, you need to ensure that this 
> library also supports java.time.Instant values. This Java type is not a 
> part of JDBC specification and only few drivers (including driver of H2) 
> support it natively. Java persistence libraries also aren't required to 
> know this data type. It looks like you need to write an own data type 
> converter. For example, in JPA, converters implement 
> jakarta.persistence.AttributeConverter or 
> javax.persistence.AttributeConverter depending on version of JPA 
> implementation. In your case an implementation of 
> org.springframework.core.convert.converter.Converter seems to be 
> required. spring-data-commons project has 
> org.springframework.data.convert.Jsr310Converters class with some 
> converters for java.time.Instant type, but it doesn't have a converter 
> between java.time.OffsetDateTime (JDBC data type for TIMESTAMP WITH TIME 
> ZONE SQL data type) and java.time.Instant.
>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to h2-database+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/h2-database/6023ea5a-059e-4538-a23c-bb1ea9720edan%40googlegroups.com.

Reply via email to