LocalDateTime does not round-trip (DST issue)

I’m using a TIMESTAMP column in the database mapped to a LocalDateTime field in the entity; and I expected this to be a lossless mapping.

However, when persisting 2026-03-29T02:30:41 and reading it back, I get 2026-03-29T03:30:41. The problem seems to be that TimestampJdbcType / getBinder / doBind tries to convert 2026-03-29T02:30:41 to a java.sql.Timestamp – but that timestamp does not exist in the JVM time zone (because of the CET → CEST switch), so 2026-03-29T03:30:41 is used instead.

Background: I wanted to use LocalDateTime to eliminate any time zone issues in the intermediate layers, but this does not seem to work out. Of course, there are other options; I was just surprised to find out that LocalDateTime in this context is not time-zone-independent. Is there anything that can be done to fix the LocalDateTime behavior?

Test with Spring Boot 4.0.5 and Hibernate 7.2.7

Entity:

@Entity
public class TestEntity {

    @Id
    private Long id;

    private LocalDateTime localDateTime;

    // getters and setters
}

Test:

@Test
void test() {
    TestEntity testEntity = new TestEntity();
    testEntity.setId(1L);
    testEntity.setLocalDateTime(LocalDateTime.parse("2026-03-29T02:30:41"));
    entityManager.persist(testEntity);
    entityManager.flush();
    entityManager.clear();

    TestEntity testEntity2 = entityManager.find(TestEntity.class, 1L);
    assertThat(testEntity2.getLocalDateTime()).isEqualTo(testEntity.getLocalDateTime());
}

Thanks.

If you want to avoid time zone issues, you will have to either use an Instant or configure your JVM timezone to UTC. Any other temporal data will be converted, based on time zone information.