550 words

Issue #52 - NPE at com.objectdb.jpa.JpaQuery.getResultList

BugVersion: 2.2.7Priority: NormalStatus: ClosedReplies: 3
#1
2011-07-02 10:59

This is very similar to issue #51  raised by kaosko .   So perhaps I should have added it there.  Anyway, here it is....

 

[ObjectDB 2.2.7_03] Unexpected exception (Error 990)
  Generated by Java HotSpot(TM) 64-Bit Server VM 1.6.0_25 (on Linux 2.6.16.60-0.69.1-smp).
Please report this error on http://www.objectdb.com/database/issue/new
com.objectdb.o.InternalException: java.lang.NullPointerException: null
java.lang.NullPointerException
        at com.objectdb.o.OBC.aY(OBC.java:1300)
        at com.objectdb.o.QRR.b(QRR.java:197)
        at com.objectdb.jpa.JpaQuery.getResultList(JpaQuery.java:618)
        at ie.longpat.jpa.entity.control.MomentPayloadController.findMomentPayloadEntities(MomentPayloadController.java:163)
    public List<MomentPayload> findMomentPayloadEntities() {
        return findMomentPayloadEntities(true, -1, -1);
    }
 
    public List<MomentPayload> findMomentPayloadEntities(int maxResults, int firstResult) {
        return findMomentPayloadEntities(false, maxResults, firstResult);
    }
 
    private List<MomentPayload> findMomentPayloadEntities(boolean all, int maxResults, int firstResult) {
        EntityManager em = getEntityManager();
        try {
            CriteriaBuilder cb = em.getCriteriaBuilder();
            CriteriaQuery query = cb.createQuery();
            Root<MomentPayload> fromMomentPayload  = query.from(MomentPayload.class);
            query.select(fromMomentPayload);
            query.orderBy(cb.desc(fromMomentPayload.get("dateTime")));
            Query q = em.createQuery(query);
            if (!all) {
                q.setMaxResults(maxResults);
                q.setFirstResult(firstResult);
            }
            return q.getResultList();
        } finally {
            em.close();
        }
    }
longpat
longpat's picture
Joined on 2011-05-30
User Post #11
#2
2011-07-02 13:50

It seems as a separate issue. Maybe related to pessimistic locking.

Can you provide a test case? The following program throws no exception.

import java.util.*;
 
import javax.persistence.*;
import javax.persistence.criteria.*;
 
public class I52 {
 
    public static void main(String[] args) {
        new I52().findMomentPayloadEntities();
    }
 
    public List<MomentPayload> findMomentPayloadEntities() {
        return findMomentPayloadEntities(true, -1, -1);
    }
 
    public List<MomentPayload> findMomentPayloadEntities(
            int maxResults, int firstResult) {
        return findMomentPayloadEntities(false, maxResults, firstResult);
    }
 
    private List<MomentPayload> findMomentPayloadEntities(
        boolean all, int maxResults, int firstResult) {
 
        EntityManagerFactory emf =
            Persistence.createEntityManagerFactory("$objectdb/db/test.odb");
        EntityManager em = emf.createEntityManager();
 
        try {
            CriteriaBuilder cb = em.getCriteriaBuilder();
            CriteriaQuery query = cb.createQuery();
            Root<MomentPayload> fromMomentPayload  = query.from(MomentPayload.class);
            query.select(fromMomentPayload);
            query.orderBy(cb.desc(fromMomentPayload.get("dateTime")));
            Query q = em.createQuery(query);
            if (!all) {
                q.setMaxResults(maxResults);
                q.setFirstResult(firstResult);
            }
            return q.getResultList();
        }
        finally {
            em.close();
            emf.close();
        }
    }
 
    @Entity
    public static final class MomentPayload {
        java.sql.Timestamp dateTime;
    }
}

 

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #400
#3
2011-07-04 12:26

Unfortunately, I have not been able to reproduce this exception. (which is good, I suppose!)

Around the time it occurred, there was a change made to the entity persistent fields and its relationship. I think perhaps the old instances were still in the db at the time.

Anyway, I will keep a look out for its recurrence.

 

longpat
longpat's picture
Joined on 2011-05-30
User Post #12
#4
2011-07-08 00:47

Maybe the server was still running. Schema changes requires server restart.

I am closing this issue - reopen it if you have more info.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #409

Post Reply

Please read carefully the posting instructions - before posting to the ObjectDB website.

  • You may have to disable pop up blocking in order to use the toolbar (e.g. in Chrome).
  • Use ctrl + right click to open the browser context menu in the editing area (e.g. for using a browser spell checker).
  • To insert formatted lines (e.g. Java code, stack trace) - select a style in the toolbar and then insert the text in the new created block.
  • Avoid overflow of published source code examples by breaking long lines.
  • You may mark in paragraph code words (e.g. class names) with the code style (can be applied by ctrl + D).
  • Long stack traces (> 50 lines) and complex source examples (> 100 lines) should be posted as attachments.
Attachments:
Maximum file size: 32 MB
Cancel