?? select.java
字號(hào):
//$Id: Select.java,v 1.4.2.1 2003/11/27 15:28:38 oneovthafew Exp $
package net.sf.hibernate.sql;
/**
* A simple SQL <tt>SELECT</tt> statement
* @author Gavin King
*/
public class Select {
private String selectClause;
private String fromClause;
private String outerJoinsAfterFrom;
private String whereClause;
private String outerJoinsAfterWhere;
private String orderByClause;
/**
* Construct an SQL <tt>SELECT</tt> statement from the given clauses
*/
public String toStatementString() {
StringBuffer buf = new StringBuffer(
selectClause.length() +
fromClause.length() +
outerJoinsAfterFrom.length() +
whereClause.length() +
outerJoinsAfterWhere.length() +
20
);
buf.append("select ").append(selectClause)
.append(" from ").append(fromClause)
.append(outerJoinsAfterFrom)
.append(" where ").append(whereClause)
.append(outerJoinsAfterWhere);
if (orderByClause!=null && orderByClause.trim().length() > 0 ) {
buf.append(" order by ")
.append(orderByClause);
}
return buf.toString();
}
/**
* Sets the fromClause.
* @param fromClause The fromClause to set
*/
public Select setFromClause(String fromClause) {
this.fromClause = fromClause;
return this;
}
public Select setFromClause(String tableName, String alias) {
this.fromClause = tableName + ' ' + alias;
return this;
}
/**
* Sets the orderByClause.
* @param orderByClause The orderByClause to set
*/
public Select setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
return this;
}
/**
* Sets the outerJoins.
* @param outerJoinsAfterFrom The outerJoinsAfterFrom to set
* @param outerJoinsAfterWhere The outerJoinsAfterWhere to set
*/
public Select setOuterJoins(String outerJoinsAfterFrom, String outerJoinsAfterWhere) {
this.outerJoinsAfterFrom = outerJoinsAfterFrom;
this.outerJoinsAfterWhere = outerJoinsAfterWhere;
return this;
}
/**
* Sets the selectClause.
* @param selectClause The selectClause to set
*/
public Select setSelectClause(String selectClause) {
this.selectClause = selectClause;
return this;
}
/**
* Sets the whereClause.
* @param whereClause The whereClause to set
*/
public Select setWhereClause(String whereClause) {
this.whereClause = whereClause;
return this;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -