db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Doran <matt.do...@papercut.com>
Subject NPE in BasicSortObserver.getClone() when performing query with "HAVING" clause
Date Sat, 12 Jun 2010 07:04:09 GMT
Hi there,

I have a relatively simple query that triggers a NPE in derby.  The 
query is generated out of Hibernate, but it's pretty easy to understand 
(calculating users with total balances above 100).  See below.

    SELECT user0_.user_id AS col_0_0_,
    /SUM/(account2_.balance) AS col_1_0_
    FROM tbl_user user0_
    INNER JOIN tbl_user_account accountlin1_
    ON user0_.user_id = accountlin1_.user_id
    INNER JOIN tbl_account account2_
    ON accountlin1_.account_id = account2_.account_id
    WHERE user0_.deleted = 'N'
    AND ( account2_.account_type IN ( 'USER-01', 'USER' ) )
    GROUP BY user0_.user_id
    HAVING /SUM/(account2_.balance) >= 100.0


When I run this I get the following a nasty NPE ... see stack trace 
below.   If I remove the "HAVING" clause the query executes 
successfully.    I've attached a derby log with the query plans on 
showing firstly the successful query without the HAVING clause and then 
the stacktrace running the above query.

I'm running 10.4.2.0.    And can provider anyone interested a copy of 
the DB if that would help (it's only small - 500kb).

Any clues on this one?

    java.lang.NullPointerException
         at
    org.apache.derby.impl.sql.execute.BasicSortObserver.getClone(Unknown
    Source)
         at
    org.apache.derby.impl.sql.execute.BasicSortObserver.insertNonDuplicateKey(Unknown
    Source)
         at
    org.apache.derby.impl.sql.execute.AggregateSortObserver.insertNonDuplicateKey(Unknown
    Source)
         at
    org.apache.derby.impl.store.access.sort.SortBuffer.insert(Unknown
    Source)
         at
    org.apache.derby.impl.store.access.sort.MergeInserter.insert(Unknown
    Source)
         at
    org.apache.derby.impl.sql.execute.GroupedAggregateResultSet.loadSorter(Unknown
    Source)
         at
    org.apache.derby.impl.sql.execute.GroupedAggregateResultSet.openCore(Unknown
    Source)
         at
    org.apache.derby.impl.sql.execute.ProjectRestrictResultSet.openCore(Unknown
    Source)
         at
    org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl.open(Unknown
    Source)
         at
    org.apache.derby.impl.sql.GenericPreparedStatement.execute(Unknown
    Source)
         at
    org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown
    Source)
         at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown
    Source)
         at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown
    Source)
         at org.apache.derby.impl.tools.ij.ij.executeImmediate(Unknown
    Source)
         at org.apache.derby.impl.tools.ij.utilMain.doCatch(Unknown Source)
         at
    org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(Unknown Source)
         at org.apache.derby.impl.tools.ij.utilMain.go(Unknown Source)
         at org.apache.derby.impl.tools.ij.Main.go(Unknown Source)
         at org.apache.derby.impl.tools.ij.Main.mainCore(Unknown Source)
         at org.apache.derby.impl.tools.ij.Main.main(Unknown Source)
         at org.apache.derby.tools.ij.main(Unknown Source)




Regards,
Matt


Mime
View raw message