- Type Parameters:
E- the type of the column the function takes and returns.- Record Components:
name- the function's name, a SQL identifier optionally qualified by a schema.
search, suggest,
orderFirst, orderBy, groupBy and a template placeholder take it as they take the column.
Its use is an expression index: the database serves a query that names the expression the index is built on.
An index on LOWER(fold_accents(last_name)) serves a search over
foldAccents.apply(Owner_.lastName), which compares as
LOWER(fold_accents(o.last_name)) LIKE LOWER(fold_accents(?)).
SqlFunction<String> foldAccents = SqlFunction.of("fold_accents");
owners.select()
.where(it -> it.search(input, foldAccents.apply(Owner_.lastName)))
.getResultList();
A comparison applies the function to both sides: to the column, and to the value the column is compared
against, so the database computes both and the application computes neither. For the text-matching operators the
value is the pattern, escaped and with its wildcards, so a function compared this way must leave the wildcards
% and _, SQL Server's [, and the escape character ! as they are.
The path names a single column. A call is not a value the result holds, so a keyset scroll key and a scroll sort field refuse it, and it never equals the path it wraps.
- Since:
- 1.16
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordSqlFunction.Call<T extends Data,E> The call of a function on a path. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the call of this function on the given path, which a query takes where it takes the path.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static booleanReturnstrueif the path is a function call, directly or as the key it is viewed as.name()Returns the value of thenamerecord component.static <E> SqlFunction<E> Returns the function of the given name.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
SqlFunction
Creates an instance of aSqlFunctionrecord class.- Parameters:
name- the value for thenamerecord component
-
-
Method Details
-
of
Returns the function of the given name.- Type Parameters:
E- the type of the column the function takes and returns.- Parameters:
name- the function's name, a SQL identifier optionally qualified by a schema.- Returns:
- the function.
-
apply
Returns the call of this function on the given path, which a query takes where it takes the path.- Type Parameters:
T- the root table type of the path.- Parameters:
path- the column to apply the function to.- Returns:
- the call.
-
isCall
Returnstrueif the path is a function call, directly or as the key it is viewed as.- Parameters:
path- the path to test.- Returns:
truefor a function call.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-