Java exception when using @CreationTimestamp or @UpdateTimestamp annotation in Embeddable

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?

Make sure you must be used over Date or Calendar object

you may be used for the Long object.

if you use

@CreareTimestame

Date createTime

@UpdateTimestamp

Date updateTime

If you can replicate it with this test case templates, you should open a Jira issue.

I’m using the Calendar object as shown below.

@Column(insertable = false, updatable = false, nullable = false)
@CreationTimestamp
@Temporal(TemporalType.TIMESTAMP)
private java.util.Calendar createdOn;

@Column(insertable = false, updatable = false, nullable = false)
@UpdateTimestamp
@Temporal(TemporalType.TIMESTAMP)
private java.util.Calendar updatedOn;

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

like:
@Entity
public class MyEntity {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = “id”, updatable = false, nullable = false)
private Long id;

@Column
private String value;

@Column
@CreationTimestamp
private LocalDateTime createDateTime;

@Column
@UpdateTimestamp
private LocalDateTime updateDateTime;

…

}

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?

Sound like a bug. You should add a Jira issue for this and provide a replicating test case.

Hi Valad,

Is this issue resolved.
is resolved then in which version it will be applicable.

Please confirm.

It’s only an issue if there’s a replicating test case. If you can replicate it, then you should open a Jira issue.

Hi,

I created jira issue with issue Id=HHH-13235 and URL= https://hibernate.atlassian.net/browse/HHH-13235

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.