Top Description Fields Constructors Methods
org.hibernate.loader.plan.exec.query.internal

public Class SelectStatementBuilder

extends Object
Class Inheritance
Imports
org.hibernate.LockMode, .LockOptions, org.hibernate.dialect.Dialect, org.hibernate.internal.util.StringHelper

Largely a copy of the org.hibernate.sql.Select class, but changed up slightly to better meet needs of building a SQL SELECT statement from a LoadPlan
Authors
Steve Ebersole, Gavin King

Field Summary

Modifier and TypeField and Description
private String
public final Dialect
private StringBuilder
private int
private LockOptions
private StringBuilder
private String
private String
private StringBuilder
private StringBuilder

Constructor Summary

AccessConstructor and Description
public
SelectStatementBuilder(Dialect
The dialect.
dialect
)

Constructs a select statement builder object.

Method Summary

Modifier and TypeMethod and Description
public void
appendFromClauseFragment(String
The from cause fragment.
fragment
)

Appends the from clause fragment.

public void
appendFromClauseFragment(String
The table name.
tableName
,
String
The table alias.
alias
)

Appends the specified table name and alias as a from clause fragment.

public void
appendOrderByFragment(String
The "order by" fragment to append.
ordering
)

Appends the "order by" fragment, prefixed by a comma if the "order by" fragment already exists.

public void
appendRestrictions(String
The restrictions.
restrictions
)

Appends the specified restrictions after "cleaning" the specified value (by trimming and removing 'and ' from beginning and ' and' from the end).

public void
appendSelectClauseFragment(String
The selection fragment
selection
)

Appends a select clause fragment

private String
cleanRestrictions(String restrictions)

private boolean
private boolean
public void
setComment(String
The comment.
comment
)

Sets the comment for the select statement.

public void
setLockMode(LockMode
The lock mode.
lockMode
)

Sets the lock mode for the select statement.

public void
setLockOptions(LockOptions
The lock options.
lockOptions
)

Sets the lock options for the select statement.

public void
setOuterJoins(String
The outer join fragment to be appended to the "from" clause.
outerJoinsAfterFrom
,
String
The outer join fragment to be appended to the "where" clause.
outerJoinsAfterWhere
)

Sets the outer join fragments to be added to the "from" and "where" clauses.

public String

Returns:

the SQL SELECT statement.
toStatementString
()

Construct an SQL SELECT statement from the given clauses.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

commentback to summary
private String comment
dialectback to summary
public final Dialect dialect
fromClauseback to summary
private StringBuilder fromClause
guesstimatedBufferSizeback to summary
private int guesstimatedBufferSize
lockOptionsback to summary
private LockOptions lockOptions
orderByClauseback to summary
private StringBuilder orderByClause
outerJoinsAfterFromback to summary
private String outerJoinsAfterFrom
outerJoinsAfterWhereback to summary
private String outerJoinsAfterWhere
selectClauseback to summary
private StringBuilder selectClause
whereClauseback to summary
private StringBuilder whereClause

Constructor Detail

SelectStatementBuilderback to summary
public SelectStatementBuilder(Dialect dialect)

Constructs a select statement builder object.

Parameters
dialect:Dialect

The dialect.

Method Detail

appendFromClauseFragmentback to summary
public void appendFromClauseFragment(String fragment)

Appends the from clause fragment.

Parameters
fragment:String

The from cause fragment.

appendFromClauseFragmentback to summary
public void appendFromClauseFragment(String tableName, String alias)

Appends the specified table name and alias as a from clause fragment.

Parameters
tableName:String

The table name.

alias:String

The table alias.

appendOrderByFragmentback to summary
public void appendOrderByFragment(String ordering)

Appends the "order by" fragment, prefixed by a comma if the "order by" fragment already exists.

Parameters
ordering:String

The "order by" fragment to append.

appendRestrictionsback to summary
public void appendRestrictions(String restrictions)

Appends the specified restrictions after "cleaning" the specified value (by trimming and removing 'and ' from beginning and ' and' from the end). If the where clause already exists, this method ensure that ' and ' prefixes the cleaned restrictions.

Parameters
restrictions:String

The restrictions.

appendSelectClauseFragmentback to summary
public void appendSelectClauseFragment(String selection)

Appends a select clause fragment

Parameters
selection:String

The selection fragment

cleanRestrictionsback to summary
private String cleanRestrictions(String restrictions)
isNotEmptyback to summary
private boolean isNotEmpty(String string)
isNotEmptyback to summary
private boolean isNotEmpty(StringBuilder builder)
setCommentback to summary
public void setComment(String comment)

Sets the comment for the select statement.

Parameters
comment:String

The comment.

setLockModeback to summary
public void setLockMode(LockMode lockMode)

Sets the lock mode for the select statement.

Parameters
lockMode:LockMode

The lock mode.

setLockOptionsback to summary
public void setLockOptions(LockOptions lockOptions)

Sets the lock options for the select statement.

Parameters
lockOptions:LockOptions

The lock options.

setOuterJoinsback to summary
public void setOuterJoins(String outerJoinsAfterFrom, String outerJoinsAfterWhere)

Sets the outer join fragments to be added to the "from" and "where" clauses.

Parameters
outerJoinsAfterFrom:String

The outer join fragment to be appended to the "from" clause.

outerJoinsAfterWhere:String

The outer join fragment to be appended to the "where" clause.

toStatementStringback to summary
public String toStatementString()

Construct an SQL SELECT statement from the given clauses.

Returns:String

the SQL SELECT statement.