In OpenJPA, when a relationship attribute has either a @OneToOne or a @ManyToOne
annotation with a @Column annotation, the @Column annotation is treated
as a @JoinColumn annotation. EclipseLink throws
an exception that indicates that the entity class must use @JoinColumn instead of
@Column to map a relationship attribute.
This rule flags @Column annotations that are used with OneToOne
or ManyToOne annotations.
An automated fix will replace the @Column annotation with a @JoinColumn
annotation.
All corresponding annotation attributes are copied to the @JoinColumn annotation.
The javax.persistence.Column elements length, precision,
and scale are not copied.
For example, this rule flags the Column annotation in the following entity class:
import javax.persistence.Entity; import javax.persistence.Column; import javax.persistence.Id; import javax.persistence.ManyToOne; @Entity public class TransactionEntity { @Id private int id; private long transactionNumber; private double amount; @ManyToOne @Column(name="account") private Account account; }
An automated fix will replace the @Column annotation with a
@JoinColumn annotation and provides the appropriate imports.
import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.ManyToOne; import javax.persistence.JoinColumn; @Entity public class TransactionEntity { @Id private int id; private long transactionNumber; private double amount; @ManyToOne @JoinColumn(name="account") private Account account; }
For information about this issue and other OpenJPA to EclipseLink migration issues, see the OpenJPA to EclipseLink JPA Migration: Mappings guide.