jakartaee / persistence

https://jakartaee.github.io/persistence/
Other
206 stars 59 forks source link

Introduce row value constructor syntax #90

Open lukasj opened 10 years ago

lukasj commented 10 years ago

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:

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'.

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}*
lukasj commented 6 years ago
lukasj commented 10 years ago

@glassfishrobot Commented Reported by c.beikov

lukasj commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA JPA_SPEC-90

beikov commented 2 years ago

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.