I'm using the following code for a generated date column. It works for inserts, but not update. Any ideas?
Code:
@ValueGenerationType(generatedBy = FunctionCreationUpdateValueGeneration.class)
@Retention(RetentionPolicy.RUNTIME)
public @interface FunctionCreationUpdateTimestamp {
}
Code:
public class FunctionCreationUpdateValueGeneration implements AnnotationValueGeneration<FunctionCreationUpdateTimestamp> {
@Override
public String getDatabaseGeneratedReferencedColumnValue() {
return "SYSDATE";
}
@Override
public GenerationTiming getGenerationTiming() {
return GenerationTiming.ALWAYS;
}
@Override
public ValueGenerator<?> getValueGenerator() {
return null;
}
@Override
public boolean referenceColumnInSql() {
return true;
}
@Override
public void initialize(FunctionCreationUpdateTimestamp arg0, Class<?> arg1) {}
}
Code:
@FunctionCreationUpdateTimestamp
@Column(name="update_date", insertable=false, updatable=false)
@Temporal(value=TemporalType.TIMESTAMP)
private Date lastUpdated;