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

Mark Lilback commented on OPENJPA-2429:
---------------------------------------

I'm seeing the same bug. Here are the details:

Class RCUser has:

        @Id
        private int id;
        @OneToMany(targetEntity = Project.class, fetch = FetchType.LAZY, 
mappedBy = "user", cascade = CascadeType.ALL)
        @OrderBy("name DESC")
        private Set<Project> projects = new HashSet<Project>();

Class Project has:
        @Id
        private int id;
        @Basic
        private String name;
        @ManyToOne(fetch=FetchType.LAZY)
        @JoinColumn(name="userid", nullable=false)
        private RCUser user;

My resource basically does the following with input values of pid and pname:
                em.getTransaction().begin();
                p = em.find(Project.class, pid);
                p.setName(pname);
                em.getTransaction().commit();

I do lots of validation on the input, it is all valid and not-null.

relevant stack trace lines are:

org.apache.openjpa.persistence.RollbackException: null
        at 
org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:594)
 ~[openjpa-all-2.2.0.jar:2.2.0]
Caused by: org.apache.openjpa.persistence.PersistenceException: null
        at 
org.apache.openjpa.kernel.BrokerImpl.afterCompletion(BrokerImpl.java:2034) 
~[openjpa-all-2.2.0.jar:2.2.0]
Caused by: java.lang.NullPointerException: null
        at 
org.apache.openjpa.datacache.DataCachePCDataImpl.clearInverseRelationCache(DataCachePCDataImpl.java:179)
 ~[openjpa-all-2.2.0.jar:2.2.0]
        at 
org.apache.openjpa.datacache.DataCachePCDataImpl.storeField(DataCachePCDataImpl.java:159)
 ~[openjpa-all-2.2.0.jar:2.2.0]
        at org.apache.openjpa.kernel.PCDataImpl.store(PCDataImpl.java:263) 
~[openjpa-all-2.2.0.jar:2.2.0]

If I comment out the @OrderBy line, no exception is raised.


> NPE was thrown out when a @OrderBy modified column is being persisted.
> ----------------------------------------------------------------------
>
>                 Key: OPENJPA-2429
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2429
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: datacache
>    Affects Versions: 2.2.1
>         Environment: Windows 7
> WebSphere 8.5
>            Reporter: Kymair Wu
>
> Following NPE was thrown out when a @OrderBy modified column is being 
> persisted.
> {quote}
> Caused by: java.lang.NullPointerException
>         at 
> org.apache.openjpa.datacache.DataCachePCDataImpl.clearInverseRelationCache(DataCachePCDataImpl.java:179)
>         at 
> org.apache.openjpa.datacache.DataCachePCDataImpl.storeField(DataCachePCDataImpl.java:159)
> {quote}
> I notice that getOrderDeclaration() of FieldMetaData will return null when 
> both _orders and _orderDec are null, which cause the NPE.
> The only place _orders will be set after class initialization seems to be 
> getOrders()? But getOrders() is not involved for all the FieldMetaData of 
> "fields[i].getInverseMetaDatas()"
> I'm not sure whether this is a OpenJPA issue but whether this NPE should be 
> handled internally? 
> Google returns a potential case but no more information found. See 
> https://issues.apache.org/jira/browse/OPENJPA-2096?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
>  and 
> http://mail-archives.apache.org/mod_mbox/openjpa-users/201006.mbox/%[email protected]%3E
> Thanks!



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to