openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sascha Just (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (OPENJPA-1978) Using a MappedSuperclass with IdClass causes NullPointerException in OpenJPA when having classes with persistent fields of the superclass type.
Date Thu, 05 May 2011 11:28:03 GMT

    [ https://issues.apache.org/jira/browse/OPENJPA-1978?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13029290#comment-13029290
] 

Sascha Just commented on OPENJPA-1978:
--------------------------------------

Thanks for your reply Rick. 
Changing the targetEntity does indeed solve the problem (at least for the test case I submitted).
I can't test this on the productive code since we changed the model of this module and switched
to a InheritanceType.JOINED strategy.
Your suggestion works in both scenarios:

private A a;

@ManyToOne (cascade = CascadeType.ALL, fetch = FetchType.LAZY, targetEntity = A.class) 
    public A getA() { 
    return this.a; 
} 

and 

private B a;

@ManyToOne (cascade = CascadeType.ALL, fetch = FetchType.LAZY, targetEntity = B.class) 
    public B getA() { 
    return this.a; 
} 

I actually can't remember why we set the targetEntity to the superclass in the first place.

Anyways, OpenJPA is pretty good with error handling and should throw a non-fatal user exception
(containing an appropriate error message) instead of crashing with a NullPointerException
if the targetEntity points to the abstract superclass and the return type is a (non-abstract)
subclass of the targetEntity.



> Using a MappedSuperclass with IdClass causes NullPointerException in OpenJPA when having
classes with persistent fields of the superclass type. 
> ------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-1978
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1978
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.1.0
>         Environment: independent, tested on Mac OS X (10.5/10.6) and Linux 2.6.32
>            Reporter: Sascha Just
>         Attachments: openjpa-nullpointerexception.tar.gz, stacktrace.txt
>
>
> We got a MappedSuperclass A with IdClass APK. The class B extends A using inheritance
type 'TAPE_PER_CLASS'. 
> The class C holds a field of type A. OpenJPA crashes with a NullPointerException in org.apache.openjpa.jdbc.meta.MappingInfo#mergeColumn.

> We tried different annotation strategies to tackle this problem but didn't find a way
to get rid of the NullPointerException. While looking at the bug database we found a lot of
issues that might be related to this problem but weren't able to track down the cause of the
error.
> I will attach a stacktrace and a maven project containing a testcase for the above scenario
reproducing the error.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message