persistence icon indicating copy to clipboard operation
persistence copied to clipboard

Introduce row value constructor syntax

Open lukasj opened this issue 11 years ago • 4 comments

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

  • 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}*

lukasj avatar Aug 13 '14 16:08 lukasj

  • Issue Imported From: https://github.com/javaee/jpa-spec/issues/90
  • Original Issue Raised By:@glassfishrobot
  • Original Issue Assigned To: @ldemichiel

lukasj avatar Aug 31 '18 16:08 lukasj

@glassfishrobot Commented Reported by c.beikov

lukasj avatar Aug 13 '14 16:08 lukasj

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

lukasj avatar May 05 '17 06:05 lukasj

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.

beikov avatar Mar 18 '22 12:03 beikov