Introduce row value constructor syntax
SQL-92 introduced the row value constructor and JPA should support it. Even though some databases do not support the syntax of SQL-92, it can be emulated as has been shown by JOOQ:
- https://github.com/jOOQ/jOOQ/blob/master/jOOQ/src/main/java/org/jooq/impl/RowSubqueryCondition.java
- https://github.com/jOOQ/jOOQ/blob/master/jOOQ/src/main/java/org/jooq/impl/RowInCondition.java
- https://github.com/jOOQ/jOOQ/blob/master/jOOQ/src/main/java/org/jooq/impl/RowCondition.java
Hibernate even supports that syntax already as document here: https://docs.jboss.org/hibernate/orm/4.2/manual/en-US/html_single/#queryhql-tuple
The changes in the JPQL BNF would require to copy the following rules and giving the copies a suffix like '_1'.
- arithmetic_primary
- string_expression
- boolean_expression
- enum_expression
- datetime_expression
- entity_expression
- entity_type_expression
Then transform the original rules like the following where R is the respecitve rule name
R ::= R_1 | { (R_1 {, R_1}*) }
Of course the naming is stupid but it allows this generic transformation description.
Null comparison and IN expressions follow the same scheme
null_comparison_expression ::=
{null_comparison_expression_simple | {( null_comparison_expression_simple {, null_comparison_expression_simple}* )} } IS [NOT] NULL
null_comparison_expression_simple ::=
{single_valued_path_expression | input_parameter}
in_expression ::=
in_expression_lhs [NOT] IN
{ ( in_item {, in_item}* ) | (subquery) | collection_valued_input_parameter }
in_expression_lhs ::=
in_expression_lhs_simple | {( in_expression_lhs_simple {, in_expression_lhs_simple}* )} )
in_expression_lhs_simple ::=
{state_valued_path_expression | type_discriminator}
in_item ::=
in_item_simple | {( in_item_simple {, in_item_simple}* )} )
in_item_simple ::= literal | single_valued_input_parameter
And finally the subquery should also be able to have more than one select item.
simple_select_clause ::= SELECT [DISTINCT] simple_select_expression {, simple_select_expression}*
- Issue Imported From: https://github.com/javaee/jpa-spec/issues/90
- Original Issue Raised By:@glassfishrobot
- Original Issue Assigned To: @ldemichiel
@glassfishrobot Commented Reported by c.beikov
@glassfishrobot Commented This issue was imported from java.net JIRA JPA_SPEC-90
FWIW Hibernate 6.0 implements support for this in HQL and the JPA Criteria API extension. If anyone is willing to work on the spec parts, Hibernate can serve as a compatible implementation.