Class RawSqlBuilder

  extended by com.avaje.ebean.RawSqlBuilder

public class RawSqlBuilder
extends Object


Builds RawSql instances from a SQL string and column mappings.

Note that RawSql can also be defined in ebean-orm.xml files and be used as a named query.

See Also:

Field Summary
static String IGNORE_COLUMN
          Special property name assigned to a DB column that should be ignored.
Method Summary
 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.
static RawSqlBuilder parse(String sql)
          Return a DRaw parsing the sql.
static RawSqlBuilder unparsed(String sql)
          Return an unparsed DRaw.
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


public static final String IGNORE_COLUMN
Special property name assigned to a DB column that should be ignored.

See Also:
Constant Field Values
Method Detail


public static RawSqlBuilder unparsed(String sql)
Return an unparsed DRaw. Unlike a parsed one this query can not be modified - so no additional WHERE or HAVING expressions can be added to this query.


public static RawSqlBuilder parse(String sql)
Return a DRaw parsing the 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)
Set the mapping of a DB Column to a bean property.

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 property
propertyName - the bean property that we are mapping the DB column to.


public RawSqlBuilder columnMappingIgnore(String dbColumn)
Ignore this DB column. It is not mapped to any bean property.


public RawSql create()
Create the immutable RawSql object. Do this after all the column mapping has been defined.

Copyright © 2010. All Rights Reserved.