本文整理汇总了Java中net.sf.jsqlparser.statement.select.PlainSelect.getTop方法的典型用法代码示例。如果您正苦于以下问题:Java PlainSelect.getTop方法的具体用法?Java PlainSelect.getTop怎么用?Java PlainSelect.getTop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.jsqlparser.statement.select.PlainSelect
的用法示例。
在下文中一共展示了PlainSelect.getTop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import net.sf.jsqlparser.statement.select.PlainSelect; //导入方法依赖的package包/类
@Override
public void visit(PlainSelect plainSelect) {
if (plainSelect.getDistinct() != null && plainSelect.getDistinct().getOnSelectItems() != null) {
plainSelect.getDistinct().getOnSelectItems().forEach(s -> s.accept(this));
}
if (plainSelect.getFromItem() != null) {
plainSelect.getFromItem().accept(this);
}
if (plainSelect.getGroupByColumnReferences() != null) {
plainSelect.getGroupByColumnReferences().forEach(s -> s.accept(this));
}
if (plainSelect.getHaving() != null) {
plainSelect.getHaving().accept(this);
}
if (plainSelect.getJoins() != null) {
plainSelect.getJoins().forEach(
j -> {
visitJoin(j);
}
);
}
if (plainSelect.getOrderByElements() != null) {
plainSelect.getOrderByElements().forEach(s -> s.accept(this));
}
if (plainSelect.getSelectItems() != null) {
plainSelect.getSelectItems().forEach(s -> s.accept(this));
}
if (plainSelect.getTop() != null) {
plainSelect.getTop().getExpression().accept(this);
}
if (plainSelect.getWhere() != null) {
plainSelect.getWhere().accept(this);
}
if (plainSelect.getLimit() != null) {
visitLimit(plainSelect.getLimit());
}
}
示例2: plainSelectToStringAppendWithNoLock
import net.sf.jsqlparser.statement.select.PlainSelect; //导入方法依赖的package包/类
private static String plainSelectToStringAppendWithNoLock(PlainSelect plain) {
StringBuilder sql = new StringBuilder("SELECT ");
if (plain.getDistinct() != null)
sql.append(plain.getDistinct()).append(" ");
if (plain.getTop() != null)
sql.append(plain.getTop()).append(" ");
sql.append(PlainSelect.getStringList(plain.getSelectItems()));
if (plain.getFromItem() != null) {
sql.append(" FROM ").append(plain.getFromItem()).append(" WITH (NOLOCK) ");
if (plain.getJoins() != null) {
Iterator<Join> it = plain.getJoins().iterator();
while (it.hasNext()) {
Join join = it.next();
if (join.isSimple()) {
sql.append(", ").append(join).append(" WITH (NOLOCK) ");
} else {
String temp = join.toString().replace(join.getRightItem().toString(),
join.getRightItem().toString() + " WITH (NOLOCK) ");
sql.append(" ").append(temp);
}
}
}
if (plain.getWhere() != null)
sql.append(" WHERE ").append(plain.getWhere());
if (plain.getOracleHierarchical() != null)
sql.append(plain.getOracleHierarchical().toString());
sql.append(PlainSelect.getFormatedList(plain.getGroupByColumnReferences(), "GROUP BY"));
if (plain.getHaving() != null)
sql.append(" HAVING ").append(plain.getHaving());
sql.append(PlainSelect.orderByToString(plain.isOracleSiblings(), plain.getOrderByElements()));
if (plain.getLimit() != null)
sql.append(plain.getLimit());
}
return sql.toString();
}