In my SQL Server 2000 database, I have a timestamp (in function not in data type) column of type datetime named lastTouched set to (getdate()) as its default value/binding.
I am using the Netbeans 6.5 generated JPA entity classes, and have this in my code
@Basic(optional = false)
@Column(name = "LastTouched")
@Temporal(TemporalType.TIMESTAMP)
private Date lastTouched;
However when I try to put the object into the database I get,
javax.persistence.PersistenceException: org.hibernate.PropertyValueException: not-null property references a null or transient value: com.generic.Stuff.lastTouched
I've tried setting setting the @Basic to (optional = true), but that throws a exception saying the database doesn't allow null values for the timestamp column, which it doesn't by design.
ERROR JDBCExceptionReporter - Cannot insert the value NULL into column 'LastTouched', table 'DatabaseName.dbo.Stuff'; column does not allow nulls. INSERT fails.
I previously got this to work in pure Hibernate, but I have sense switched over to JPA and have no idea how to tell it that this column is suppose to be generated on the database side. Note that I am still using Hiberate as my JPA persistance layer.