C
chrislewis
Hello,
I am trying to have certain values created/updated when a new record
is created or an existing one is updated. I'm using the following
field (using hibernate annotations as demonstrated in Hibernate In
Action):
@Column(updatable = false, insertable = false)
@org.hibernate.annotations.Generated(
org.hibernate.annotations.GenerationTime.INSERT
)
private Date created;
Its simple; all I want is the 'created' field to be provided by
hibernate as a timestamp for when it was created. Similarly, I want a
timestamp field (named 'modified') to be updated whenever the record
is changed. For that I have:
@Column(updatable = false, insertable = false)
@org.hibernate.annotations.Generated(
org.hibernate.annotations.GenerationTime.ALWAYS
)
private Date modified;
Unfortunately neither of these work. From the book as well as other
documentation (the website), I can't see that I'm doing anything
incorrectly, but the behavior I'm getting is that both of these fields
are always null. Can anyone see what I've done wrong (or not doing)?
Sincerely,
Chris
I am trying to have certain values created/updated when a new record
is created or an existing one is updated. I'm using the following
field (using hibernate annotations as demonstrated in Hibernate In
Action):
@Column(updatable = false, insertable = false)
@org.hibernate.annotations.Generated(
org.hibernate.annotations.GenerationTime.INSERT
)
private Date created;
Its simple; all I want is the 'created' field to be provided by
hibernate as a timestamp for when it was created. Similarly, I want a
timestamp field (named 'modified') to be updated whenever the record
is changed. For that I have:
@Column(updatable = false, insertable = false)
@org.hibernate.annotations.Generated(
org.hibernate.annotations.GenerationTime.ALWAYS
)
private Date modified;
Unfortunately neither of these work. From the book as well as other
documentation (the website), I can't see that I'm doing anything
incorrectly, but the behavior I'm getting is that both of these fields
are always null. Can anyone see what I've done wrong (or not doing)?
Sincerely,
Chris