[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[eclipselink-users] Internal ClassCastException in 2.1: @OrderBy not respecting user collection type
|
I have an entity with a @OneToMany field. It's mapped like this:
@OneToMany(cascade = { CascadeType.PERSIST, CascadeType.REMOVE },
mappedBy = "foo", targetEntity = BarEntity.class)
@OrderBy
private Collection<Bar> stuff;
I discovered that if I initialize this myself like this in, say, the
constructor:
this.stuff = new LinkedHashSet<Bar>();
...I get a class cast exception during persist that says:
java.lang.ClassCastException: java.util.LinkedHashSet cannot be cast
to java.util.List
at org.eclipse.persistence.internal.queries.OrderedListContainerPolicy.iteratorFor(OrderedListContainerPolicy.java:429)
at org.eclipse.persistence.mappings.CollectionMapping.cascadeRegisterNewIfRequired(CollectionMapping.java:369)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.cascadeRegisterNewForCreate(ObjectBuilder.java:1684)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerNewObjectForPersist(UnitOfWorkImpl.java:4212)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.persist(EntityManagerImpl.java:384)
Is there some section of the JPA 2.0 specification that says what
collection types are permitted? Or that the kind of Collection
annotated by @OrderBy must be a List? Is this pilot error or a bug?
Thanks,
Laird