Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » JOINED-@Inheritance, MappedSuperclass with multiple @Id fields
JOINED-@Inheritance, MappedSuperclass with multiple @Id fields [message #508600] Tue, 19 January 2010 15:24 Go to next message
kurt Mising name is currently offline kurt Mising nameFriend
Messages: 12
Registered: July 2009
Junior Member
Having a MappedSuperclass with at least 2 @Id-fields as superclass for a baseclass with @Inheritance(JOINED) and finally a child class. Trying to generate the tables out of this gives the stacktrace below.

In Eclipse, the childclass' @Entity has an error-marker which says: 'In implied attribute override "id1", column "id1" cannot be resolved'

It looks like the information on the second @Id-field gets lost "somewhere".


Hope somebody can tell me if anything is missing (annotation or whatever) on my classes or I found the next bug ...


Thanks
Kurt


stacktrace:

Exception in thread "main" Local Exception Stack:
Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.PersistenceUnitLoadingExc eption
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@11b86e7
Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.EntityManagerSetupExcepti on
Exception Description: Predeployment of PersistenceUnit [Test_JPA] failed.
Internal Exception: java.lang.NullPointerException
at org.eclipse.persistence.exceptions.PersistenceUnitLoadingExc eption.exceptionSearchingForPersistenceResources(Persistence UnitLoadingException.java:126)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntity ManagerFactory(PersistenceProvider.java:133)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntity ManagerFactory(PersistenceProvider.java:65)
at javax.persistence.Persistence.createEntityManagerFactory(Per sistence.java:78)
at org.eclipse.jpt.eclipselink.core.ddlgen.Main.execute(Main.ja va:75)
at org.eclipse.jpt.eclipselink.core.ddlgen.Main.main(Main.java: 63)
Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.EntityManagerSetupExcepti on
Exception Description: Predeployment of PersistenceUnit [Test_JPA] failed.
Internal Exception: java.lang.NullPointerException
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl. predeploy(EntityManagerSetupImpl.java:986)
at org.eclipse.persistence.internal.jpa.deployment.JPAInitializ er.callPredeploy(JPAInitializer.java:88)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntity ManagerFactory(PersistenceProvider.java:124)
... 4 more
Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.EntityManagerSetupExcepti on
Exception Description: Predeployment of PersistenceUnit [Test_JPA] failed.
Internal Exception: java.lang.NullPointerException
at org.eclipse.persistence.exceptions.EntityManagerSetupExcepti on.predeployFailed(EntityManagerSetupException.java:210)
... 7 more
Caused by: java.lang.NullPointerException
at org.eclipse.persistence.internal.jpa.metadata.MetadataDescri ptor.setPKClass(MetadataDescriptor.java:1516)
at org.eclipse.persistence.internal.jpa.metadata.inheritance.In heritanceMetadata.process(InheritanceMetadata.java:152)
at org.eclipse.persistence.internal.jpa.metadata.accessors.clas ses.EntityAccessor.processTableAndInheritance(EntityAccessor .java:1294)
at org.eclipse.persistence.internal.jpa.metadata.accessors.clas ses.EntityAccessor.process(EntityAccessor.java:690)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProjec t.processStage2(MetadataProject.java:1333)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProces sor.processORMMetadata(MetadataProcessor.java:461)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceU nitProcessor.processORMetadata(PersistenceUnitProcessor.java :390)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl. predeploy(EntityManagerSetupImpl.java:940)
... 6 more



testclasses:

package asas;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

@MappedSuperclass
public class MSCBase
implements Serializable {

private static final long serialVersionUID = 1L;

@Id
@Column(nullable = false, length = 2)
private String id0;

@Id
@Column(nullable = false, length = 15)
private String id1;

public String getId0() {
return id0;
}

public void setId0(final String id0) {
this.id0 = id0;
}

public String getId1() {
return id1;
}

public void setId1(final String id1) {
this.id1 = id1;
}

}


package asas;

import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.MappedSuperclass;

// @MappedSuperclass
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "TYP", length = 1, discriminatorType = DiscriminatorType.STRING)
public class JCBase
extends MSCBase {

private static final long serialVersionUID = 1L;

private String name;

private String typ;

public String getName() {
return name;
}

public void setName(final String name) {
this.name = name;
}

public String getTyp() {
return typ;
}

public void setTyp(final String typ) {
this.typ = typ;
}
}


package asas;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;

@Entity
@DiscriminatorValue("C")
public class JCChild
extends JCBase {

private static final long serialVersionUID = 1L;

private String vorname;

public String getVorname() {
return vorname;
}

public void setVorname(final String name) {
this.vorname = name;
}
}
Re: JOINED-@Inheritance, MappedSuperclass with multiple @Id fields [message #508839 is a reply to message #508600] Wed, 20 January 2010 14:20 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1039
Registered: July 2009
Senior Member
Please file a bug for the NullPointerException. EclpseLink should throw an exception stating that the problem is the MappedSuperclass MSCBase has mutliple Id fields but does not have a PKClass defined instead of throwing the NPE.

The JPA specification requires a PKClass be defined if using a composite primary key. Adding one will correct the problem.

Best Regards,
Chris
Re: JOINED-@Inheritance, MappedSuperclass with multiple @Id fields [message #509347 is a reply to message #508600] Fri, 22 January 2010 08:01 Go to previous message
kurt Mising name is currently offline kurt Mising nameFriend
Messages: 12
Registered: July 2009
Junior Member
did so: https://bugs.eclipse.org/bugs/show_bug.cgi?id=300458

thx
kurt
Previous Topic:doesn't find method definition!!!!!
Next Topic:Cascade type ALL not propagating
Goto Forum:
  


Current Time: Fri Dec 19 08:05:26 GMT 2014

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

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