java - Overriding @Id defined in a @MappedSuperclass -
i have class abstractentity extended entities in application , acts identifier provider.
@mappedsuperclass public class abstractentity implements domainentity { private static final long serialversionuid = 1l; /** object's id */ @id @generatedvalue(strategy = generationtype.auto) protected long id; @temporal(temporaltype.timestamp) @column(name="creation_date", nullable = false, updatable=false) private date creationdate = new date(); /** * @return id */ public long getid() { return this.id; } /** * @param id id set */ public void setid(long id) { this.id = id; } }
i have case need define separate id couple of entity classes these need have custom sequence generator. how can achieved?
@entity @table(name = "sample_entity") public class childentity extends abstractchangeableentity { @column(name = "batch_priority") private int priority; public int getpriority() { return priority; } public void setpriority(int priority) { this.priority = priority; }
}
you can't it. check github example if want.
once define @id
in base class won't able override in sub-class, meaning it's better leave @id
responsibility each individual concrete class.
Comments
Post a Comment