Return-Path: X-Original-To: apmail-openjpa-dev-archive@www.apache.org Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E7CDB966A for ; Thu, 27 Sep 2012 19:49:07 +0000 (UTC) Received: (qmail 75148 invoked by uid 500); 27 Sep 2012 19:49:07 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 75088 invoked by uid 500); 27 Sep 2012 19:49:07 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 74880 invoked by uid 99); 27 Sep 2012 19:49:07 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Sep 2012 19:49:07 +0000 Date: Fri, 28 Sep 2012 06:49:07 +1100 (NCT) From: "Rick Curtis (JIRA)" To: dev@openjpa.apache.org Message-ID: <224130554.135395.1348775347605.JavaMail.jiratomcat@arcas> In-Reply-To: <1452934467.126591.1348626607725.JavaMail.jiratomcat@arcas> Subject: [jira] [Assigned] (OPENJPA-2267) native query select with null result causes NullPointerException MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/OPENJPA-2267?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Rick Curtis reassigned OPENJPA-2267: ------------------------------------ Assignee: Rick Curtis > native query select with null result causes NullPointerException > ---------------------------------------------------------------- > > Key: OPENJPA-2267 > URL: https://issues.apache.org/jira/browse/OPENJPA-2267 > Project: OpenJPA > Issue Type: Bug > Components: query > Affects Versions: 2.2.0 > Environment: my system is fedora 16, MySql 5.5.18 (running innodb), jdk1.6.0_26, openjdk 2.2.0 (also happened in 2.1.0), mysql-connector-java 5.1.18, commons-dbcp 1.4, spring 3.1.1 > Reporter: Ted Leung > Assignee: Rick Curtis > Priority: Minor > > if you do a native query with a null resultset where the resulting object is not the model object, it causes a null pointer exception. > --------------------------------------------------- > mysql> desc Data; > +--------------------------+--------------+------+-----+---------+----------------+ > | Field | Type | Null | Key | Default | Extra | > +--------------------------+--------------+------+-----+---------+----------------+ > | id | bigint(20) | NO | PRI | NULL | auto_increment | > | data | mediumblob | YES | | NULL | | > +--------------------------+--------------+------+-----+---------+----------------+ > 12 rows in set (0.01 sec) > mysql> select count(*) from Data; > +----------+ > | count(*) | > +----------+ > | 0 | > +----------+ > 1 row in set (0.00 sec) > mysql> select max(id) from Data; > +---------+ > | max(id) | > +---------+ > | NULL | > +---------+ > 1 row in set (0.00 sec) > now in java do : > Query query = entityManager.createNativeQuery("select max(id) from Data", Long.class); > List results = query.getResultList(); > The following exception ensues. > --------------------------------------------------- > org.apache.openjpa.persistence.ArgumentException: Failed to execute query "select max(id) from Data". Check the query syntax for correctness. See nested exception for details. > at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:872) > at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:794) > at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:542) > at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:286) > at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:302) > ... > Caused by: java.lang.NullPointerException > at org.apache.openjpa.kernel.ResultPacker.pack(ResultPacker.java:202) > at org.apache.openjpa.jdbc.kernel.SQLProjectionResultObjectProvider.getResultObject(SQLProjectionResultObjectProvider.java:88) > at org.apache.openjpa.lib.rop.RangeResultObjectProvider.getResultObject(RangeResultObjectProvider.java:80) > at org.apache.openjpa.lib.rop.EagerResultList.(EagerResultList.java:36) > at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1251) > at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:1007) > at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:863) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira