[~paul4christ79] Following up more, what I can see here in the generic solution is something like what you suggest. For sake of a starting point...
{code:borderStyle=solid} public interface DynamicValueGenerator<T> { public T generateValue(Session session, Object owner); }
public @interface Dynamic { GenerationTime when() default ALWAYS; Class<? extends DynamicValueGenerator> generator(); } {code}
So your example would look like: {code:borderStyle=solid} @Dynamic( when=INSERT, generator=DynamicValueGenerator.class ) private Date when; {code}
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 And potentially: # {{@Creator}} # {{@Modifier}}
|