JPA (EclipseLink) can't seem to handle an inheritance hierarchy 3 levels deep [message #716795] |
Thu, 18 August 2011 09:38  |
Eclipse User |
|
|
|
The EclipseLink implementation of the JPA seems to have problems processing the following class hierarchy anyone have any ideas why?
public interface X {
String code();
}
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class XImpl implements X {
@Id
@Column(name = "code")
String code;
public XImpl(String code) {
this.code = code;
}
public String code() {
return code;
}
}
public interface Y {
}
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class YImpl implements Y {
@Id
@OneToOne(targetEntity = XImpl.class, cascade = { CascadeType.PERSIST,
CascadeType.MERGE })
@JoinColumn(name = "code")
protected X x;
public YImpl(X x) {
this.x = x;
}
}
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class Z extends YImpl {
public Z(X x) {
super(x);
}
}
The following exception occurs:
Caused by: java.util.NoSuchElementException
at java.util.AbstractList$Itr.next(AbstractList.java:350)
at org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor.getPrimaryKeyField(MetadataDescriptor.java:972)
at org.eclipse.persistence.internal.jpa.metadata.accessors.MetadataAccessor.getReferencedField(MetadataAccessor.java:398)
at org.eclipse.persistence.internal.jpa.metadata.accessors.MetadataAccessor.getReferencedField(MetadataAccessor.java:386)
at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.addMultipleTableKeyFields(EntityAccessor.java:181)
at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.processInheritancePrimaryKeyJoinColumns(EntityAccessor.java:1009)
at org.eclipse.persistence.internal.jpa.metadata.inheritance.InheritanceMetadata.processInheritanceSubclass(InheritanceMetadata.java:284)
at org.eclipse.persistence.internal.jpa.metadata.inheritance.InheritanceMetadata.process(InheritanceMetadata.java:219)
at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.processInheritance(EntityAccessor.java:986)
at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.processTableAndInheritance(EntityAccessor.java:1200)
at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.process(EntityAccessor.java:589)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage2(MetadataProject.java:1541)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:485)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:454)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1081)
... 31 more
|
|
|
Re: JPA (EclipseLink) can't seem to handle an inheritance hierarchy 3 levels deep [message #716914 is a reply to message #716795] |
Thu, 18 August 2011 15:02  |
Eclipse User |
|
|
|
The Z class should not have the @Inheritance annotation as it will use its parents, but there should be a better exception if that is the cause.
What version of EclipseLink are you using, and can you try the latest nightly builds? Can you also try creating a basic mapping for your the code field and marking it as YImpl's ID and setting the OneToOne to X as insertable=false, updateable=false ?
Best Regards,
Chris
|
|
|
(no subject) [message #716918 is a reply to message #716795] |
Thu, 18 August 2011 15:02  |
Eclipse User |
|
|
|
The Z class should not have the @Inheritance annotation as it will use its parents, but there should be a better exception if that is the cause.
What version of EclipseLink are you using, and can you try the latest nightly builds? Can you also try creating a basic mapping for your the code field and marking it as YImpl's ID and setting the OneToOne to X as insertable=false, updateable=false ?
Best Regards,
Chris
|
|
|
Powered by
FUDForum. Page generated in 0.05790 seconds