How to override hibernate collection join column?

hibernate, java

Solution

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 {

}

Problem

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?

Original source