When I try to iterate over a collection of embeddable objects, I get the following exception:
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to com.kryterion.wa.core.model.ftp.FtpSubdirectory I'm very confused by this...I have the Pro JPA 2 book and closely followed its example of the Employee class and its element collection of embeddable Vacation bookings. When I look at the collection while debugging, I see that the subdirectories field is an ArrayList proxy which has a field called elementData, which is an Object array. When I inspect the first element of this Object array, I see that it too is an Object array with three string elements (the path, type, and description values). Basically, I don't see that OpenJPA loaded up a collection of FtpSubdirectory objects as I would've expected, and hence the class cast exception. My mappings: @Entity @Table(name = "core_ftp_connection") public class FtpConnection extends AbstractMultiNamedEntity { private static final long serialVersionUID = 1L; ... @ElementCollection(targetClass = FtpSubdirectory.class, fetch = FetchType.EAGER) @CollectionTable(name = "core_ftp_subdir", joinColumns = @JoinColumn(name = "fk_ftp_connection_id")) private Collection<FtpSubdirectory> subdirectories = new ArrayList<FtpSubdirectory>(); ... and @Embeddable public class FtpSubdirectory { @Column(name = "path") private String path; @Column(name = "type") @Enumerated(EnumType.STRING) private SubdirectoryType type; @Column(name = "description") private String description; public String getPath() { return path; } ... -- View this message in context: http://openjpa.208410.n2.nabble.com/ClassCast-exception-while-iterating-over-an-element-collection-of-embeddables-tp7580378.html Sent from the OpenJPA Users mailing list archive at Nabble.com.