public class SqlProjection extends QueryProjection
Projection that selects the value of a native SQL expression, created by sqlProjection or
sqlGroupProjection in a criteria query. In the SQL, {alias} stands for the table alias of the
queried entity.
The SQL of a sqlProjection may select several columns, separated by commas, each one optionally
followed by as and its column alias, as on Hibernate 5. It is split into one projection per column, so
every column is a selection of its own.
| Constructor and description |
|---|
SqlProjection(java.lang.String sql, java.lang.String columnAlias, java.lang.Object type)
|
| Type Params | Return Type | Name and description |
|---|---|---|
|
public java.lang.String |
getColumnAlias()Returns the alias of the projected column, which names it in an order of the criteria query. |
|
public java.lang.Object |
getDeclaredType()Returns the type of the projected value as it was given: an org.hibernate.type.StandardBasicTypes
constant or an org.hibernate.type.Type, which also tell how the value is read, a Java class or
null. |
|
public java.lang.String |
getSql()Returns the SQL expression of the projected column, without its column alias. |
|
public java.lang.Class<?> |
getType()Returns the Java type of the projected value. |
|
public static java.util.List<SqlProjection> |
of(java.lang.String sql, java.util.List<java.lang.String> columnAliases, java.util.List<?> types)Splits the SQL of a sqlProjection or sqlGroupProjection into one projection per column. |
sql - the SQL expression of the projected column, without its column aliascolumnAlias - the alias of the projected columntype - the type of the projected value: an org.hibernate.type.StandardBasicTypes constant, an
org.hibernate.type.Type, a Java class or null for a value of any type Returns the alias of the projected column, which names it in an order of the criteria query.
Returns the type of the projected value as it was given: an org.hibernate.type.StandardBasicTypes
constant or an org.hibernate.type.Type, which also tell how the value is read, a Java class or
null.
Returns the SQL expression of the projected column, without its column alias.
Returns the Java type of the projected value.
Splits the SQL of a sqlProjection or sqlGroupProjection into one projection per column.
sql - the SQL selecting the columns, separated by commascolumnAliases - the alias of each column, in ordertypes - the type of each column, in order: an org.hibernate.type.StandardBasicTypes constant, an
org.hibernate.type.Type or a Java class