Community
Participate
Working Groups
Always reproducible. Case : @Entity class ShoppingCart implements Serializable { @Id private String ID; @OneToMany(cascade = { CascadeType.ALL, CascadeType.REMOVE }, orphanRemoval = true, mappedBy = "cart") @MapKey(name = "keyref") private Map<String, Item> items = new HashMap<String, Item>(); // Getters, Setters... } @Entity @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(discriminatorType = DiscriminatorType.STRING, name = "type") public abstract class Item implements Serializable { @Id private String ID; private String keyref; @ManyToOne @JoinColumn(name = "cart_ID", referencedColumnName = "ID") private ShoppingCart cart; // Getters, Setters... } @Entity @DiscriminatorValue(value = "ConcreteItem") public class ConcreteItem extends Item { ... } class SessionMgr { public void save(ShoppingCart cart) { ... EntityTransaction transaction = entitymanager.getTransaction(); ... transaction.begin(); entitymanager.persist(cart); transaction.commit(); } } On commit the produced Stacktrace is: javax.persistence.RollbackException: Exception [EclipseLink-34] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.DescriptorException Exception Description: This class does not define a public default constructor, or the constructor raised an exception. Internal Exception: java.lang.InstantiationException Descriptor: RelationalDescriptor(com.blah.Item --> [DatabaseTable(item)]) at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:102) at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:63) at com.blah.SessionMgr.save(SessionMgr.java:...) However, if I modify my ShoppingCart like this: @Entity class ShoppingCart implements Serializable { @Id private String ID; @OneToMany(cascade = { CascadeType.ALL, CascadeType.REMOVE }, orphanRemoval = true, mappedBy = "cart") private List<Item> items = new ArrayList<Item>(); // Getters, Setters... } There's no issue
previous case modification to reproduce: @MappedSuperClass class Cart implements Serializable { @Id private String ID; // Getters, Setters... } @Entity class ShoppingCart extends Cart { @OneToMany(cascade = { CascadeType.ALL, CascadeType.REMOVE }, orphanRemoval = true, mappedBy = "cart") @MapKey(name = "key") private Map<String, Item> items = new HashMap<String, Item>(); // Getters, Setters... } @Entity @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(discriminatorType = DiscriminatorType.STRING, name = "type") public abstract class Item implements Serializable { @Id private String ID; private String key; @ManyToOne @JoinColumn(name = "cart_ID", referencedColumnName = "ID") private ShoppingCart cart; // Getters, Setters... } It seems that changing MapKey from "key" to "keyref" solves the problem...
It is not clear to me which of the cases you have posted reproduces the problem, the one in the initial post, the one in the second post, or both. Can you please clarify. Can you please also clarify your comment about "key" vs. "keyref".
Setting target and priority. See the following page for the meanings of these fields: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines Still awaiting information requested above.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink