Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » JPA (EclipseLink) can't seem to handle an inheritance hierarchy 3 levels deep(EclipseLink and inheritance hierarchy)
JPA (EclipseLink) can't seem to handle an inheritance hierarchy 3 levels deep [message #716795] Thu, 18 August 2011 13:38 Go to next message
Mika  is currently offline Mika Friend
Messages: 1
Registered: August 2011
Junior Member
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 19:02 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
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 19:02 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
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
Previous Topic:JPA BigDecimal scale difference between Oracle and DB2
Next Topic:(no subject)
Goto Forum:
  


Current Time: Thu Mar 28 08:56:58 GMT 2024

Powered by FUDForum. Page generated in 0.04376 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top