Database.queryUsingSQL throws NullPointerException when the SQL statement has max clause.

Database.queryUsingSQL throws NullPointerException when the SQL statement has max clause.

book

Article ID: KB0084817

calendar_today

Updated On:

Products Versions
TIBCO BusinessEvents Enterprise Edition -
Not Applicable -

Description

Resolution:
Description:
==========
When trying to execute a SQL statement with max clause, function Database.queryUsingSQL threw NullPointerException. If max clause was removed, no exception is thrown.

Environment:
==========
TIBCO BusinessEvents - 4.x
OS - All

Symptoms:
=========
1). Using DB Concepts and invoking method " Database.queryUsingSQL".

2). If the SQL statement has MAX function, NullPointerException is generated. If same SQL statement is used without MAX function, it executes successfully.

Cause:
======
Database.queryUsingSQL is a RDBMS function. It queries DB unlike BQL queries which are for querying cache. This function returns a Concept resultset (Concept[]) instead of certain column set. It is not possible to cast the max(column) to a Concept so it throws the NullPointerException.

Resolution:
=========
To get the maximum value of a column, change the SQL statement by adding a max clause in the where clause. This selects the Concepts which has the maximum value of a specific column from the target table.

Issue/Introduction

Database.queryUsingSQL throws NullPointerException when the SQL statement has max clause.