When inserting an Entity that contains a column annotated with @CreationTimestamp, inserting throws this ClassCastException:
This is my test entity:
@Entity
public class TestEntity {
@Id
int id;
@CreationTimestamp @Column
Instant createdAt;
}
And this my testcase:
var session = entityManager.unwrap(Session.class);
try (var statelessSession = session.getSessionFactory().openStatelessSession()) {
statelessSession.getTransaction().begin();
statelessSession.insert(new TestEntity());
statelessSession.getTransaction().commit();
}
I attached a Spring boot 3.0.3 project showcasing the issue. spring-boot-hibernate-class-cast-demo.zip Might be related to or even a duplicate of https://hibernate.atlassian.net/browse/HHH-11048 |