public class RawSqlBuilder extends Object
Note that RawSql can also be defined in ebean-orm.xml files and be used as a named query.
RawSql
Modifier and Type | Field and Description |
---|---|
static String |
IGNORE_COLUMN
Special property name assigned to a DB column that should be ignored.
|
Modifier and Type | Method and Description |
---|---|
RawSqlBuilder |
columnMapping(String dbColumn,
String propertyName)
Set the mapping of a DB Column to a bean property.
|
RawSqlBuilder |
columnMappingIgnore(String dbColumn)
Ignore this DB column.
|
RawSql |
create()
Create the immutable RawSql object.
|
protected RawSql.Sql |
getSql()
Return the internal parsed Sql object (for testing).
|
static RawSqlBuilder |
parse(String sql)
Return a RawSqlBuilder parsing the sql.
|
static RawSql |
resultSet(ResultSet resultSet,
String... propertyNames)
Create and return a RawSql object based on the resultSet and list of properties the columns in
the resultSet map to.
|
RawSqlBuilder |
tableAliasMapping(String tableAlias,
String path)
Modify any column mappings with the given table alias to have the path prefix.
|
static RawSqlBuilder |
unparsed(String sql)
Return an unparsed RawSqlBuilder.
|
public static final String IGNORE_COLUMN
public static RawSql resultSet(ResultSet resultSet, String... propertyNames)
The properties listed in the propertyNames must be in the same order as the columns in the resultSet.
public static RawSqlBuilder unparsed(String sql)
public static RawSqlBuilder parse(String sql)
The sql statement will be parsed so that Ebean can determine where it can insert additional WHERE or HAVING expressions.
Additionally the selected columns are parsed to determine the column ordering. This also means additional checks can be made with the column mapping - specifically we can check that all columns are mapped and that correct column names are entered into the mapping.
public RawSqlBuilder columnMapping(String dbColumn, String propertyName)
For Unparsed SQL the columnMapping MUST be defined in the same order that the columns appear in the SQL statement.
dbColumn
- the DB column that we are mapping to a bean propertypropertyName
- the bean property that we are mapping the DB column to.public RawSqlBuilder columnMappingIgnore(String dbColumn)
public RawSqlBuilder tableAliasMapping(String tableAlias, String path)
For example modify all mappings with table alias "c" to have the path prefix "customer".
For the "Root type" you don't need to specify a tableAliasMapping.
public RawSql create()
protected RawSql.Sql getSql()
Copyright © 2016. All rights reserved.