persistence@glassfish.java.net

JPQL NPE with update query and subquery (issue 572)

From: Michael Bouschen <Michael.Bouschen_at_Sun.COM>
Date: Wed, 19 Apr 2006 18:22:13 +0200

Hi Tom,

attached you find my changes to fix the NPE in the JPQL compiler when
compiling an UPDATE query including a subquery.

The SubqueryNode creates a ReportQuery instance for the subquery and
then calls the subQuery method on the query's base expression passing
the ReportQuery. The issue is that the base expression is only set for a
SELECT query.

I added some code initializing the base expression for UPDATE and DELETE
queries. Most of the code to be changed/added is identical for UPDATE
and DELETE, so I decided to add a new superclass ModifyNode for
UpdateNode and DeleteNode. I also added a new method to ModifyAllQuery
allowing to set the query's ExpressionBuilder.

Please have a look at the attached changes. Thanks!

Regards Michael