Uploaded image for project: 'Cayenne'
  1. Cayenne
  2. CAY-2541

Performing query with expression with ObjectId throws NPE in some cases

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.0.2, 4.1.B1
    • 4.2.M1
    • Core Library
    • None

    Description

      NPE when using expression with ObjectId.

      Case:

      ObjectId id = new ObjectId("Artist", "ID", 1);

      ASTDbPath astDbPath = new ASTDbPath("ID");
      ASTScalar astScalar = new ASTScalar(id);

      ASTEqual astEqual = new ASTEqual();
      astEqual.setOperand(0, astDbPath);
      astEqual.setOperand(1, astScalar);

      ObjectSelect.query(Artist.class)
      .where(astEqual)
      .selectFirst(context);

       

      StackTrace:

      java.lang.NullPointerException
      at org.apache.cayenne.access.translator.select.QualifierTranslator.appendObjectMatch(QualifierTranslator.java:205)
      at org.apache.cayenne.access.translator.select.QualifierTranslator.endNode(QualifierTranslator.java:483)
      at org.apache.cayenne.exp.Expression.traverse(Expression.java:609)
      at org.apache.cayenne.exp.Expression.traverse(Expression.java:581)
      at org.apache.cayenne.access.translator.select.QualifierTranslator.doAppendPart(QualifierTranslator.java:120)
      at org.apache.cayenne.access.translator.select.QualifierTranslator.doAppendPart(QualifierTranslator.java:87)
      at org.apache.cayenne.access.translator.select.QueryAssemblerHelper.appendPart(QueryAssemblerHelper.java:76)
      at org.apache.cayenne.access.translator.select.DefaultSelectTranslator.doTranslate(DefaultSelectTranslator.java:152)
      at org.apache.cayenne.access.translator.select.QueryAssembler.ensureTranslated(QueryAssembler.java:130)
      at org.apache.cayenne.access.translator.select.QueryAssembler.getSql(QueryAssembler.java:121)
      at org.apache.cayenne.access.jdbc.SelectAction.performAction(SelectAction.java:91)
      at org.apache.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQueryAction.java:97)
      at org.apache.cayenne.access.DataNode.performQueries(DataNode.java:293)
      at org.apache.cayenne.access.DataDomainQueryAction.runQuery(DataDomainQueryAction.java:471)
      at org.apache.cayenne.access.DataDomainQueryAction.access$000(DataDomainQueryAction.java:72)
      at org.apache.cayenne.access.DataDomainQueryAction$2.perform(DataDomainQueryAction.java:446)
      at org.apache.cayenne.tx.DefaultTransactionManager.performInTransaction(DefaultTransactionManager.java:87)
      at org.apache.cayenne.tx.DefaultTransactionManager.performInTransaction(DefaultTransactionManager.java:51)
      at org.apache.cayenne.tx.DefaultTransactionManager.performInTransaction(DefaultTransactionManager.java:40)
      at org.apache.cayenne.access.DataDomainQueryAction.runQueryInTransaction(DataDomainQueryAction.java:443)
      at org.apache.cayenne.access.DataDomainQueryAction.execute(DataDomainQueryAction.java:122)
      at org.apache.cayenne.access.DataDomain.onQueryNoFilters(DataDomain.java:564)
      at org.apache.cayenne.access.DataDomain$DataDomainQueryFilterChain.onQuery(DataDomain.java:748)
      at org.apache.cayenne.tx.TransactionFilter.onQuery(TransactionFilter.java:49)
      at org.apache.cayenne.access.DataDomain$DataDomainQueryFilterChain.onQuery(DataDomain.java:748)
      at org.apache.cayenne.access.DataDomain.onQuery(DataDomain.java:556)
      at org.apache.cayenne.util.ObjectContextQueryAction.runQuery(ObjectContextQueryAction.java:406)
      at org.apache.cayenne.util.ObjectContextQueryAction.executePostCache(ObjectContextQueryAction.java:107)
      at org.apache.cayenne.util.ObjectContextQueryAction.execute(ObjectContextQueryAction.java:94)
      at org.apache.cayenne.access.DataContext.onQuery(DataContext.java:965)
      at org.apache.cayenne.access.DataContext.performQuery(DataContext.java:954)
      at org.apache.cayenne.BaseContext.select(BaseContext.java:307)
      at org.apache.cayenne.BaseContext.selectFirst(BaseContext.java:331)
      at org.apache.cayenne.query.ObjectSelect.selectFirst(ObjectSelect.java:660)

      Attachments

        Issue Links

          Activity

            People

              aarrsseni Arseni Bulatski
              aarrsseni Arseni Bulatski
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 10m
                  10m