Paul Benedict Following up more, what I can see here in the generic solution is something like what you suggest. For sake of a starting point...
public interface DynamicValueGenerator<T> {
public T generateValue(Session session, Object owner);
}
public @interface Dynamic {
GenerationTime when() default ALWAYS;
Class<? extends DynamicValueGenerator> generator();
}
So your example would look like:
@Dynamic( when=INSERT, generator=DynamicValueGenerator.class )
private Date when;
As examples of simplified, special-use solutions I'd like to see:
-
@CreationTimestamp
-
allow specifying whether to store DATE, TIME, TIMESTAMP (JPA TemporalType maybe)
-
allow specifying "source" (aka "db" or "vm").
-
(for source=db) allow specifying whether it is trigger generated or whether we need to embed call to the "current timestamp" function in the INSERT
-
@ModificationTimestamp
-
allow specifying whether to store DATE, TIME, TIMESTAMP (JPA TemporalType maybe)
-
allow specifying "source" (aka "db" or "vm").
-
(for source=db) allow specifying whether it is trigger generated or whether we need to embed call to the "current timestamp" function in the INSERT
-
@Creator
-
@Modifier
|