Skip to main content

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

Hello,

I'm wondering why it works then without the primary key class in eclipselink 1.1.x.
Is it by intention or just luck?


Regards,
Sascha Broich

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

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




> -----Ursprüngliche Nachricht-----
> Von: eclipselink-users-bounces@xxxxxxxxxxx [mailto:eclipselink-users-
> bounces@xxxxxxxxxxx] Im Auftrag von Christopher Delahunt
> Gesendet: Dienstag, 15. Dezember 2009 16:10
> An: eclipselink-users@xxxxxxxxxxx
> Betreff: Re: [eclipselink-users] JPA 2.0 Problem: NPE
> 
> Hello,
> 
> The JPA spec requires a primary key class defined if you have a
> composite primary key.  You need to define a key class on the root
> entity if you want it to have more than one field annotated with @Id.
> 
> Best Regards,
> Chris
> 
> 
> ----- Original Message -----
> From: sascha.broich@xxxxxx
> To: eclipselink-users@xxxxxxxxxxx
> Sent: Tuesday, December 15, 2009 6:18:30 AM GMT -05:00 US/Canada
> Eastern
> Subject: [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().getPKCl
> ass());
>       }
> 
> 
> 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
> 
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users

Back to the top