My JPA Entity classes have a @PrePersist method to set an INSERT_TIME column:
@PrePersist
protected void onCreate() {
insertTime = new Date(); // TODO: inject time source?
}
For testing, I would like to replace new Date()
so that entities are persisted with predictable data. My first thought was to have a data provider injected into the Entity class, but I don't control the creation of Entity classes, so it doesn't seem there is a way for me to inject dependencies. Any suggestions?