openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Vorburger (JIRA)" <>
Subject [jira] Commented: (OPENJPA-602) NullPointerException at
Date Fri, 16 May 2008 09:58:55 GMT


Michael Vorburger commented on OPENJPA-602:

-----Original Message-----
From: Fay Wang [] 
Sent: jeudi, 15. mai 2008 00:52
Subject: RE: NPE at RelationToManyInverseKeyFieldStrategy when using mappedBy inverse

Here is my finding: The NPE problem is the combination of (1) abstract class, (2) inheritance
strategy of TABLE_PER_CLASS, and (3) toMany relationship. When you have (1) and (2), or (1)
and (3), or (2) and (3), you will be fine.  However, when the three things are put together,
the class strategy of this entity class becomes NoneClassStrategy (since abstract class with
inheritance strategy of TABLE_PER_CLASS will not have a corresponding database table). With
NoneClassStrategy, the foreign key required for the toMany relationship will not be constructed,
resulting in NPE. I am not clear whether JPA spec ever mentioned that no relation fields in
the abstract class when inheritance strategy is table per concrete class. If not, this seems
to be a bug in OpenJPA.

@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public abstract class EntityA { 

    private Long id;
    private Long version;

    private java.util.Set<EntityB> entityBs;

    public java.util.Set<EntiytB> getEntityBs() {
          return entityBs;

    public void setEntityBs(java.util.Set<EntityB> entityBs) {
	  this.entityBs = entityBs;

If you only have (1) and (2), you will be fine because 

-----Original Message-----
From: Fay Wang [] 
Sent: mercredi, 14. mai 2008 18:45
Subject: RE: NPE at RelationToManyInverseKeyFieldStrategy when using mappedBy inverse

I take it back. I found that when I put the fields and methods in EntityBase class directly
in the Translatable class instead of having Translatable inherit from EntityBase class, I
still get NPE. This problem seems having nothing to do with MappedSuperclass annotation.


-----Original Message-----
From: Fay Wang [] 
Sent: mercredi, 14. mai 2008 18:23
Subject: RE: NPE at RelationToManyInverseKeyFieldStrategy when using mappedBy inverse

Hi Mike,
    Your super class EntityBase is annotated as @MappedSuperclass. Your Translatable class
which inherits from EntityBase has inheritance strategy of TABLE_PER_CLASS. Since MappedSuperclass
itself is not a persistence class and can not act in the capacity of an entity, it does not
have a corresponding table in the database. I think this is why openjpa got confused and could
not find foreign key between the parent class and the child class. When I removed Inheritance
strategy annotation from Translatable class, your test case went through. Having said that,
I think the NPE should be fixed and proper error message should be thrown.


> NullPointerException at
> -----------------------------------------------------------------------------------------------------
>                 Key: OPENJPA-602
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 1.1.0
>            Reporter: Michael Vorburger
>            Priority: Minor
>         Attachments: FullStackTrace-OPENJPA-602.txt,
> The example I'll attach crashes with an NPE when running the mappingtool.
> Caused by: java.lang.NullPointerException
> 	at
> 	at
> 	at org.apache.openjpa.jdbc.meta.FieldMapping.setStrategy(
> 	at org.apache.openjpa.jdbc.meta.RuntimeStrategyInstaller.installStrategy(
> 	at org.apache.openjpa.jdbc.meta.FieldMapping.resolveMapping(
> 	at org.apache.openjpa.jdbc.meta.FieldMapping.resolve(
> 	at org.apache.openjpa.jdbc.meta.ClassMapping.resolveMapping(
> The goal of this JIRA is not (neccessarily) to support the kind of mapping that would
be required for this (which may be hard), but to at least print a clear error and not an NPE...

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message