OpenJPA creates a separate table for collection attributes that are annotated with
org.apache.openjpa.persistence.PersistentCollection. To have the same
behavior in EclipseLink, replace these annotations with the @ElementCollection and @Column annotations
as defined in the JPA specification. If you remove the @PersistentCollection
annotation and do not add the @ElementCollection and @Column annotations,
EclipseLink treats the field as a BLOB and
tries to create a column for the data in the entity's table.
This rule scans for org.apache.openjpa.persistence.PersistentCollection
annotations so that you can manually migrate them.
To migrate the annotations, perform the following steps:
@org.apache.openjpa.persistence.PersistentCollection annotation with
@javax.persistence.ElementCollection @javax.persistence.Column(name="element")If there is already a
@Column annotation on the attribute,
do not add another one or change the name.
For example, this rule flags the @PersistentCollection annotation in
the following entity class:
import javax.persistence.Entity; import javax.persistence.Id; import org.apache.openjpa.persistence.PersistentCollection; @Entity public class IntArrayEntity{ @Id private int id; @PersistentCollection private int[] arrayOfInts; } |
To migrate this entity, replace the annotation and change the int array
to a list of Integer objects: List<Integer>.
import javax.persistence.Column; import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.Id; @Entity public class IntArrayEntity{ @Id private int id; @ElementCollection @Column(name="element") private List<Integer> arrayOfInts; } |
For information about this OpenJPA to EclipseLink migration issue, see the Migration from OpenJPA to EclipseLink JPA: Extended Functionality guide.