Skip to content

Commit a466ffe

Browse files
committed
document the syntax sugar
1 parent 2c08833 commit a466ffe

File tree

7 files changed

+44
-1
lines changed

7 files changed

+44
-1
lines changed

documentation/src/main/asciidoc/querylanguage/Expressions.adoc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,18 @@ select substring(title, 1, position(' for Dummies' in title)) from Book
900900
select substring(title from 1 for position(' for Dummies' in title)) from Book /* ANSI SQL-style */
901901
----
902902

903+
Alternatively, slicing may be performed using an operator, which is just syntax sugar for the `substring()` function:
904+
905+
[source, hql]
906+
----
907+
select title[1:position(' for Dummies' in title)] from Book /* Operator-style */
908+
----
909+
910+
[source,hql]
911+
----
912+
select name.first[1]||name.last[1] as initials from Author
913+
----
914+
903915
[discrete]
904916
===== Trimming strings
905917
The `trim()` function follows the syntax and semantics of ANSI SQL.
@@ -1179,6 +1191,21 @@ On supported platforms, HQL provides a rich suite of functions for working with:
11791191
- link:{doc-user-guide-url}#hql-functions-xml[XML]
11801192

11811193
The use of these functions is outside the scope of this guide.
1194+
However, we note that the following language constructs work with arrays, and are implemented as syntactic sugar for the underlying functions:
1195+
1196+
[[array-syntax-sugar]]
1197+
|===
1198+
| Syntax | Interpretation
1199+
1200+
| `[1, 2]` | Instantiate an array
1201+
| `array[1]` | Array element
1202+
| `array[1:2]` | Array slice
1203+
| `length(array)` | Length of an array
1204+
| `position(element in array)` | Position of an element within an array
1205+
| `cast(array as String)` | Typecast array to string
1206+
| `element in array` or `array contains element` | Determine if an element belongs to an array
1207+
| `array includes subarray` | Determine if the elements of one array include all the elements of a second array
1208+
|===
11821209

11831210
[[embedding-sql]]
11841211
==== Embedding SQL expressions

hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingMetadata.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@
4141
*
4242
* @author Gunnar Morling
4343
*
44+
* @deprecated Not used
4445
*/
46+
@Deprecated(since = "7", forRemoval = true)
4547
public abstract class AbstractDelegatingMetadata implements MetadataImplementor {
4648

4749
private final MetadataImplementor delegate;

hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingMetadataBuilderImplementor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@
3333
*
3434
* @param <T> The specific subclass; Allows subclasses to narrow the return type of the contract methods
3535
* to a specialization of {@link MetadataBuilderImplementor}.
36+
*
37+
* @deprecated Not used
3638
*/
39+
@Deprecated(since = "7", forRemoval = true)
3740
public abstract class AbstractDelegatingMetadataBuilderImplementor<T extends MetadataBuilderImplementor> implements MetadataBuilderImplementor {
3841

3942
private final MetadataBuilderImplementor delegate;

hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingMetadataBuildingOptions.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@
2626
*
2727
* @author Gunnar Morling
2828
* @author Steve Ebersole
29+
*
30+
* @deprecated Not used
2931
*/
30-
@SuppressWarnings("unused")
32+
@Deprecated(since = "7", forRemoval = true)
3133
public abstract class AbstractDelegatingMetadataBuildingOptions implements MetadataBuildingOptions, JpaOrmXmlPersistenceUnitDefaultAware {
3234

3335
private final MetadataBuildingOptions delegate;

hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingSessionFactoryBuilder.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@
3333
*
3434
* @param <T> The specific subclass; Allows subclasses to narrow the return type of the contract methods
3535
* to a specialization of {@link MetadataBuilderImplementor}.
36+
*
37+
* @deprecated Not used
3638
*/
39+
@Deprecated(since = "7", forRemoval = true)
3740
public abstract class AbstractDelegatingSessionFactoryBuilder<T extends SessionFactoryBuilder> implements SessionFactoryBuilder {
3841
private final SessionFactoryBuilder delegate;
3942

hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingSessionFactoryBuilderImplementor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
*
1212
* @param <T> The specific subclass; Allows subclasses to narrow the return type of the contract methods
1313
* to a specialization of {@link MetadataBuilderImplementor}.
14+
*
15+
* @deprecated Not used
1416
*/
17+
@Deprecated(since = "7", forRemoval = true)
1518
public abstract class AbstractDelegatingSessionFactoryBuilderImplementor<T extends SessionFactoryBuilderImplementor>
1619
extends AbstractDelegatingSessionFactoryBuilder<T> implements SessionFactoryBuilderImplementor {
1720

hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingSessionFactoryOptions.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@
4747
* have at least a default implementation.
4848
*
4949
* @author Steve Ebersole
50+
*
51+
* @deprecated Not used
5052
*/
53+
@Deprecated(since = "7", forRemoval = true)
5154
public class AbstractDelegatingSessionFactoryOptions implements SessionFactoryOptions {
5255
private final SessionFactoryOptions delegate;
5356

0 commit comments

Comments
 (0)