I have the following hierarchy:
Code:
@Entity
@Table(name = "TANNANN")
@Inheritance(strategy = InheritanceType.JOINED)
public class Advice {
...
}
@MappedSuperclass
public class RLAdvice extends Advice {
private Counterparty clearer;
@OneToOne(optional = false, fetch = FetchType.LAZY)
@JoinColumn(name = "")
public Counterparty getClearer() {
return clearer;
}
...
}
@Entity
@Table(name = "TSNPANN")
@PrimaryKeyJoinColumn(name = "IDXANN")
@AttributeOverrides(...)
@AssociationOverrides({
@AssociationOverride(name = "clearer", joinColumns = @JoinColumn(name = "CLEARER")),
...
})
public class SnpAdvice extends RLAdvice {
...
}
If I remove the line
Code:
@JoinColumn(name = "")
on the super class RLAdvice, I got the following exception:
Code:
org.hibernate.AnnotationException: Illegal attempt to define a @JoinColumn with a mappedBy association: clearer
at org.hibernate.cfg.Ejb3JoinColumn.buildJoinColumn(Ejb3JoinColumn.java:152)
at org.hibernate.cfg.Ejb3JoinColumn.buildJoinColumns(Ejb3JoinColumn.java:127)
at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1094)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:699)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:353)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:265)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1205)
Am I missing something or is it a bug ?