Is this really EJB-QL?
I have the following construct in EJB-QL of multiple EJB 2.1 lookup methods:
SELECT distinct OBJECT(rd) FROM RequestDetail rd, DetailResponse dr
WHERE dr.updateReqResponseParentID is not null
and dr.updateReqResponseParentID = ?1
and rd.requestDetailID = dr.requestDetailID
and rd.deleted is null and dr.deleted is null
IDEA EJB-QL FROM RequestDetail rd, DetailResponse dr
validation involves the use of two objects with validation that reads:Several ranged variable declarations are not supported, use collection member declarations instead (e.g. IN(o.lineItems))
The queries themselves work fine (as in waiting for expected results) on JBoss 4.2. Is IDEA wet here, or is there a problem with the query? And what is the actual preferred alternative syntax for such a query?
Edit: Thanks for the help from all those who answered, especially Romain. I have reported this as an issue for JetBrains.
a source to share
The request is ok - it looks like an IDEA Code Inspector issue.
I cannot find any errors related to it as such.
You might want to ask their support if you have the paid version.
I found a little problem, in the spec for EJB 2.1 (and everyone else, for that matter), it says it uses uppercase for NULL.
11.2.6.10 Expressions for Comparing Zeros
The syntax for using the IS NULL comparison operator in a conditional expression is as follows: {single_valued_path_expression | input_parameter} IS [NOT] NULL A null comparison expression tests whether an unambiguous path expression or an input parameter is NULL.
SELECT distinct OBJECT(rd) FROM RequestDetail rd, DetailResponse dr
WHERE dr.updateReqResponseParentID IS NOT NULL
and dr.updateReqResponseParentID = ?1
and rd.requestDetailID = dr.requestDetailID
and rd.deleted IS NULL and dr.deleted IS NULL
Here is a section from the EJB 2.1 specification that suits your needs ...
11.2.5.3 Variable Variable Declarations The EJB QL syntax for declaring an identity variable as a range variable is similar to SQL; it may be using the AS keyword.
range_variable_declaration :: = abstract_schema_name [AS] identifier The objects or values associated with an entity bean are usually obtained by navigation using path expressions. However, navigation does not apply to all objects. Range Variable Declarations Allow Bean The provider assigns a "root" to objects that are not navigable. If a bean provider wants to select values by comparing multiple instances of the abstract schema type of an entity bean, more than one identification variable is required in the FROM clause above the abstract schema type.
The following search method query returns orders that are greater than the order quantity for John Smith. This example illustrates the use of two different identification variables in the FROM clause as for an abstract schema type. The SELECT clause of this query specifies that these are orders with values greater than John Smiths that are returned.
SELECT DISTINCT OBJECT(o1)
FROM Order o1, Order o2
WHERE o1.quantity > o2.quantity AND
o2.customer.lastname = ‘Smith’ AND
o2.customer.firstname= ‘John’
a source to share
Assuming detailResponse is the name of the association field, whose value is a collection of DetailResponse instances, you can do this to navigate the association fields:
SELECT distinct OBJECT(rd) FROM RequestDetail rd IN (rd.detailResponse) dr WHERE
dr.updateReqResponseParentID is not null and dr.updateReqResponseParentID = ?1
and rd.deleted id null and dr.deleted is null
a source to share
I would compare requests to an official resource like BNF Grammar of EJB QL for J2EE 1.3 (since you mentioned EJB2.1)
For the later specification for JEE5 Full Request Syntax
a source to share