This is my abstract father:
@MappedSuperclass
public abstract class AbstractEntity implements Serializable {
@OneToMany(fetch = FetchType.LAZY)
@JoinColumn(name = "entity_no", referencedColumnName = "MY_COLUMN")
private Set<CLASS_TYPE> list;
}
All my entities has this set, but each entity has different referencedColumnName
.
Is there a way to override only the @JoinColumn
annotation?
You can use AssociationOverride annotation. In your case it would look like this:
@Entity
@AssociationOverrides({
@AssociationOverride(name = "list",
joinColumns = @JoinColumn(referencedColumnName = "COLUMN_NEW_NAME"))
})
public class ConcreteEntity extends AbstractEntity {
}
If you define annotations on the properties (i.e. getters) instead of on the fields, then you can override the public Set<CLASS_TYPE> getList()
in each of the sub classes and define the @JoinColumn
separately.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With