JPA: Database Generated columns
Posted
by jpanewbie
on Stack Overflow
See other posts from Stack Overflow
or by jpanewbie
Published on 2010-05-06T07:53:33Z
Indexed on
2010/05/06
7:58 UTC
Read the original article
Hit count: 164
hello
Hello,
I am facing an issue with Hiebrnate and JPA. My requirement is column CreatedDTTM and LastUPDATEDDTTM should be populated at the DB level. I have tried following but no use. My columns are set NOT NULL. I get a "cannot insert Null into LastUpdatedDttm" exception. Any guidance is appreciated.
@Column(name="LAST_UPDATED_DTTM", insertable=false, updatable=false, columnDefinition="Date default SYSDATE") @org.hibernate.annotations.Generated(value=GenerationTime.INSERT) @Temporal(javax.persistence.TemporalType.DATE) private Date lastUpdDTTM;
@Column(name="CREATED_DTTM”, insertable=false, updatable=false) @org.hibernate.annotations.Generated(value=GenerationTime.ALWAYS) @Temporal(javax.persistence.TemporalType.DATE) private Date createdDTTM;
© Stack Overflow or respective owner