Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] JPA 2.0 Problem: NPE

Hi,

I ran into an error while trying to use eclipselink 2.0.0 with javax.persistence 2.0.0.

The setting is:

I have an abstract class A with 3 primary key columns, annotated with @Id.
>From this I have derived classes B and C, with Inheritance strategy table_per_class.

Now when I try to initialize the EntityManagerFactory I get an NullpointerException at 

MetadataDescriptor.setPKClass(MetadataClass) line: 1516

        policy.setPrimaryKeyClassName(pkClass.getName());


This is because the pkClass parameter is null.


The problem, I think, is as follows. The call comes from 

InheritanceMetadata.process(MetadataDescriptor) line: 152	

	// If the root descriptor has an id class, we need to set the same 
      // id class on our descriptor.
      if (descriptor.getInheritanceRootDescriptor().hasCompositePrimaryKey()) {
          descriptor.setPKClass(descriptor.getInheritanceRootDescriptor().getPKClass());
      }


MetadataDescriptor.hasCompositePrimaryKey() method:

	return getPrimaryKeyFields().size() > 1 || getPKClass() != null


So my class A has no PKClass but 3 primary key fields.
I assume that either the  MetadataDescriptor.setPKClass has to be made NPE-safe or 
the if-statement in InheritanceMetadata.process has to be changed to "hasPKClass()".


Regards,
Sascha Broich

-- 
Sascha Broich
Entwicklung

TSA - Teleport Sachsen-Anhalt Service GmbH
Delitzscher Straße 70, 06112 Halle
Tel: +49 39203 8 2524 
E-Mail: Sascha.Broich@xxxxxx

Firmensitz: Steinfeldstraße 5, D-39179 Barleben
Geschäftsführer: Marco Langhof
Amtsgericht: Stendal HRB 6388
http://www.tsa.de



Back to the top