klyn.data.EntityManager.sqlQuery
method
public sqlQuery<T>(
sql as String,
parameters as klyn.data.sql.SQLParameters = klyn.data.sql.SQLParameters()
) as klyn.data.sql.SQLQuery<T>:
Description

Creates a re-executable typed raw SQL query.

Raw SQL is available only for an SQL-backed manager and is intentionally not composable as KQL. The result type must belong to the factory entity model, and values are always bound through a prepared statement.

Parameters
ParameterDescription
<T>Declared mapped entity result type.
sqlExplicit SQL text for the configured dialect.
parametersOrdered prepared-statement values.
Returns

Typed non-composable SQL query.

Throws
  • ProviderCapabilityException for a non-SQL manager.
  • EntityMappingException when T is not declared by the factory.
Example
users = manager.sqlQuery<User>(
"select * from T_Users where connectionNumber > ?",
SQLParameters(10)
).toList()