improvements to HQL functions examples
This commit is contained in:
parent
6c5daedfd3
commit
237e339e2c
|
@ -722,6 +722,11 @@ The `format()` function formats a date, time, or datetime according to a pattern
|
|||
|
||||
The pattern must be written in a subset of the pattern language defined by Java's `java.time.format.DateTimeFormatter`.
|
||||
|
||||
[source, hql]
|
||||
----
|
||||
select format(local datetime as 'yyyy-MM-dd HH:mm:ss')
|
||||
----
|
||||
|
||||
For a full list of `format()` pattern elements, see the Javadoc for https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/dialect/Dialect.html#appendDatetimeFormat[`Dialect.appendDatetimeFormat`].
|
||||
|
||||
[[function-trunc-datetime]]
|
||||
|
@ -735,6 +740,11 @@ The `truncate()` function truncates the precision of a date, time, or datetime t
|
|||
|
||||
Supported temporal units are: `year`, `month`, `day`, `hour`, `minute` or `second`.
|
||||
|
||||
[source, hql]
|
||||
----
|
||||
select trunc(local datetime, hour)
|
||||
----
|
||||
|
||||
Truncating a date, time or datetime value means obtaining a value of the same type in which all temporal units smaller than `field` have been pruned.
|
||||
For hours, minutes and second this means setting them to `00`. For months and days, this means setting them to `01`.
|
||||
|
||||
|
@ -759,7 +769,11 @@ Naturally, there are a good number of functions for working with strings.
|
|||
| `substring()` | Substring of a string (ANSI SQL-style)
|
||||
| `substring(str from start)`, +
|
||||
`substring(str from start for len)` | ✖ / ✔
|
||||
| `trim()` | Trim characters from string | See below | ✔ / ✔
|
||||
| `trim()` | Trim characters from string
|
||||
| `trim(str)`, +
|
||||
`trim(leading from str)`, +
|
||||
`trim(trailing from str)`, or +
|
||||
`trim(leading char from str)` | ✔ / ✔
|
||||
| `overlay()` | For replacing a substring
|
||||
| `overlay(str placing rep from start)`, +
|
||||
`overlay(str placing rep from start for len)` | ✖ / ✔
|
||||
|
@ -771,7 +785,7 @@ Naturally, there are a good number of functions for working with strings.
|
|||
| `left()` | The leftmost characters of a string | `left(str, len)` | ✖ / ✖
|
||||
| `right()` | The rightmost characters of a string | `right(str, len)` | ✖ / ✖
|
||||
| `replace()` | Replace every occurrence of a pattern in a string | `replace(str, patt, rep)` | ✖ / ✖
|
||||
| `repeat()` | Concatenate a string with itself multiple times | `replace(str, times)` | ✖ / ✖
|
||||
| `repeat()` | Concatenate a string with itself multiple times | `repeat(str, times)` | ✖ / ✖
|
||||
| `collate()` | Select a collation | `collate(p.name as collation)` | ✖ / ✖
|
||||
|===
|
||||
|
||||
|
|
|
@ -947,7 +947,7 @@ Naturally, there are a good number of functions for working with strings.
|
|||
| `substring()` | Substring of a string (JPQL-style) | `substring(s, i)`, `substring(s, i, l)` | ✓ / ✗
|
||||
| `substring()` | Substring of a string (ANSI SQL-style)
|
||||
| `substring(string from start)`, `substring(string from start for length)` | ✗ / ✓
|
||||
| `trim()` | Trim characters from string | See below | ✓ / ✓
|
||||
| `trim()` | Trim characters from string | `trim(string)`, `trim(leading from string)`, `trim(trailing from string)`, or `trim(leading character from string)` | ✓ / ✓
|
||||
| `overlay()` | For replacing a substring
|
||||
| `overlay(string placing replacement from start)`, `overlay(string placing replacement from start for length)` | ✗ / ✓
|
||||
| `pad()` | Pads a string with whitespace, or with a specified character
|
||||
|
@ -955,7 +955,7 @@ Naturally, there are a good number of functions for working with strings.
|
|||
| `left()` | The leftmost characters of a string | `left(string, length)` | ✗ / ✗
|
||||
| `right()` | The rightmost characters of a string | `right(string, length)` | ✗ / ✗
|
||||
| `replace()` | Replace every occurrence of a pattern in a string | `replace(string, pattern, replacement)` | ✗ / ✗
|
||||
| `repeat()` | Concatenate a string with itself multiple times | `replace(string, times)` | ✗ / ✗
|
||||
| `repeat()` | Concatenate a string with itself multiple times | `repeat(string, times)` | ✗ / ✗
|
||||
| `collate()` | Select a collation | `collate(p.name as collation)` | ✗ / ✗
|
||||
|===
|
||||
|
||||
|
|
Loading…
Reference in New Issue