When I use the @CreationTimestamp or @UpdateTimestamp in an embeddable java throws exception:
javax.persistence.PersistenceException: Unable to build Hibernate SessionFactory
…which is caused by:
Caused by: org.hibernate.cfg.NotYetImplementedException: Still need to wire in composite in-memory value generation
I’ve tried with both Hibernate ORM 5.1, 5.2, and 5.3 with the same results. Does anybody know if this is a reported bug or are those annotations not supported?
You can use the @CreationTimestamp and @UpdateTimestamp with the following attribute types:
java.time.LocalDate (since Hibernate 5.2.3)
java.time.LocalDateTime (since Hibernate 5.2.3)
java.util.Date
java.util.Calendar
java.sql.Date
java.sql.Time
java.sql.Timestamp
It seems to work if you do not embed it. But in my case the @CreationTimestamp and @UpdateTimestamp is in an embeddable and this is where I get the java exception mentioned. Have you tried it recently in an embedded and has it worked for you?
Thanks. You could also try to implement it if it’s urgent to you.
Otherwise, you could use @PrePersist and @PreUpdate to emulate the @CreationTimestamp and @UpdateTimestamp behavior. Check out this article for more details.