本文整理汇总了Java中net.sf.jsqlparser.statement.select.Join类的典型用法代码示例。如果您正苦于以下问题:Java Join类的具体用法?Java Join怎么用?Java Join使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Join类属于net.sf.jsqlparser.statement.select包,在下文中一共展示了Join类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addJoin
import net.sf.jsqlparser.statement.select.Join; //导入依赖的package包/类
/**
* Adds a simple join to a select statement. The introduced join is returned for
* more configuration settings on it (e.g. left join, right join).
* @param select
* @param table
* @param onExpression
* @return
*/
public static Join addJoin(Select select, final Table table, final Expression onExpression) {
if (select.getSelectBody() instanceof PlainSelect) {
PlainSelect plainSelect = (PlainSelect) select.getSelectBody();
List<Join> joins = plainSelect.getJoins();
if (joins == null) {
joins = new ArrayList<Join>();
plainSelect.setJoins(joins);
}
Join join = new Join();
join.setRightItem(table);
join.setOnExpression(onExpression);
joins.add(join);
return join;
}
throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
}
示例2: visit
import net.sf.jsqlparser.statement.select.Join; //导入依赖的package包/类
@Override
public void visit(PlainSelect plainSelect) {
if (plainSelect.getSelectItems() != null) {
for (SelectItem item : plainSelect.getSelectItems()) {
item.accept(this);
}
}
if (plainSelect.getFromItem() != null) {
plainSelect.getFromItem().accept(this);
}
if (plainSelect.getJoins() != null) {
for (Join join : plainSelect.getJoins()) {
join.getRightItem().accept(this);
}
}
if (plainSelect.getWhere() != null) {
plainSelect.getWhere().accept(this);
}
if (plainSelect.getOracleHierarchical() != null) {
plainSelect.getOracleHierarchical().accept(this);
}
}
示例3: processPlainSelect
import net.sf.jsqlparser.statement.select.Join; //导入依赖的package包/类
/**
* <p>
* 处理 PlainSelect
* </p>
*
* @param plainSelect
* @param addColumn 是否添加租户列,insert into select语句中需要
*/
protected void processPlainSelect(PlainSelect plainSelect, boolean addColumn) {
FromItem fromItem = plainSelect.getFromItem();
if (fromItem instanceof Table) {
Table fromTable = (Table) fromItem;
if (this.tenantHandler.doTableFilter(fromTable.getName())) {
// 过滤退出执行
return;
}
plainSelect.setWhere(builderExpression(plainSelect.getWhere(), fromTable));
if (addColumn) {
plainSelect.getSelectItems().add(new SelectExpressionItem(new Column(this.tenantHandler.getTenantIdColumn())));
}
} else {
processFromItem(fromItem);
}
List<Join> joins = plainSelect.getJoins();
if (joins != null && joins.size() > 0) {
for (Join join : joins) {
processJoin(join);
processFromItem(join.getRightItem());
}
}
}
示例4: JoinsList
import net.sf.jsqlparser.statement.select.Join; //导入依赖的package包/类
final public List JoinsList() throws ParseException {
ArrayList joinsList = new ArrayList();
Join join = null;
label_12:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case K_JOIN:
case K_LEFT:
case K_FULL:
case K_INNER:
case K_OUTER:
case K_RIGHT:
case K_NATURAL:
case 79:
;
break;
default:
jj_la1[61] = jj_gen;
break label_12;
}
join = JoinerExpression();
joinsList.add(join);
}
{if (true) return joinsList;}
throw new Error("Missing return statement in function");
}
示例5: visit
import net.sf.jsqlparser.statement.select.Join; //导入依赖的package包/类
public void visit(PlainSelect plainSelect) {
List<SelectItem> cols = plainSelect.getSelectItems();
for(SelectItem col : cols){
col.accept(this);
}
if(plainSelect.getFromItem()!=null){
plainSelect.getFromItem().accept(this);
}
if (plainSelect.getJoins() != null) {
for (Iterator joinsIt = plainSelect.getJoins().iterator(); joinsIt.hasNext();) {
Join join = (Join) joinsIt.next();
join.getRightItem().accept(this);
}
}
if (plainSelect.getWhere() != null)
plainSelect.getWhere().accept(this);
}
示例6: JoinsList
import net.sf.jsqlparser.statement.select.Join; //导入依赖的package包/类
final public List JoinsList() throws ParseException {ArrayList joinsList = new ArrayList();
Join join = null;
label_12:
while (true) {
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case K_JOIN:
case K_LEFT:
case K_FULL:
case K_INNER:
case K_OUTER:
case K_RIGHT:
case K_NATURAL:
case COMMA:{
;
break;
}
default:
jj_la1[65] = jj_gen;
break label_12;
}
join = JoinerExpression();
joinsList.add(join);
}
{if ("" != null) return joinsList;}
throw new Error("Missing return statement in function");
}
示例7: visit
import net.sf.jsqlparser.statement.select.Join; //导入依赖的package包/类
@Override
public void visit(PlainSelect plainSelect) {
if (plainSelect.getFromItem() != null) {
plainSelect.getFromItem().accept(this);
}
if (plainSelect.getJoins() != null) {
for (Iterator joinsIt = plainSelect.getJoins().iterator(); joinsIt.hasNext();) {
Join join = (Join) joinsIt.next();
join.getRightItem().accept(this);
}
}
if (plainSelect.getWhere() != null) {
plainSelect.getWhere().accept(this);
}
}
示例8: testFrom
import net.sf.jsqlparser.statement.select.Join; //导入依赖的package包/类
@Test
public void testFrom() throws JSQLParserException {
String statement =
"SELECT * FROM mytable as mytable0, mytable1 alias_tab1, mytable2 as alias_tab2, (SELECT * FROM mytable3) AS mytable4 WHERE mytable.col = 9";
String statementToString =
"SELECT * FROM mytable as mytable0, mytable1 as alias_tab1, mytable2 as alias_tab2, (SELECT * FROM mytable3) AS mytable4 WHERE mytable.col = 9";
PlainSelect plainSelect = (PlainSelect) ((Select) parserManager.parse(new StringReader(statement))).getSelectBody();
assertEquals(3, plainSelect.getJoins().size());
assertEquals("mytable0", ((Table) plainSelect.getFromItem()).getAlias().getName());
assertEquals("alias_tab1", ((Join) plainSelect.getJoins().get(0)).getRightItem().getAlias().getName());
assertEquals("alias_tab2", ((Join) plainSelect.getJoins().get(1)).getRightItem().getAlias().getName());
assertEquals("mytable4", ((Join) plainSelect.getJoins().get(2)).getRightItem().getAlias().getName());
assertEquals(statement.toUpperCase(), plainSelect.toString().toUpperCase());
}
示例9: getEntityAlias
import net.sf.jsqlparser.statement.select.Join; //导入依赖的package包/类
protected static String getEntityAlias(String entityName, PlainSelect query) {
FromItem fromItem = query.getFromItem();
if (hasEntityAlias(entityName, fromItem)) {
return fromItem.getAlias();
}
if (query.getJoins() != null) {
for (Object o : query.getJoins()) {
Join join = (Join) o;
if (hasEntityAlias(entityName, join.getRightItem())) {
return join.getRightItem().getAlias();
}
}
}
logger.debug("Alias from entity " + entityName + " not found in query " + query);
return null;
}
示例10: visit
import net.sf.jsqlparser.statement.select.Join; //导入依赖的package包/类
@Override
public void visit(PlainSelect ps) {
ps.getFromItem().accept(this);
if (ps.getJoins() != null) {
for (Join j : ps.getJoins()) {
j.getRightItem().accept(this);
}
}
if (ps.getWhere() != null) {
ps.getWhere().accept(this);
}
if (ps.getOracleHierarchical() != null) {
ps.getOracleHierarchical().accept(this);
}
}
示例11: toString
import net.sf.jsqlparser.statement.select.Join; //导入依赖的package包/类
@Override
public String toString() {
StringBuilder b = new StringBuilder("DELETE");
if( tables != null && tables.size() > 0){
b.append(" ");
for(Table t : tables){
b.append(t.toString());
}
}
b.append(" FROM ");
b.append(table);
if (joins != null) {
for (Join join : joins) {
if (join.isSimple()) {
b.append(", ").append(join);
} else {
b.append(" ").append(join);
}
}
}
if( where != null ){
b.append(" WHERE ").append(where);
}
if(orderByElements!=null){
b.append(PlainSelect.orderByToString(orderByElements));
}
if(limit != null){
b.append(limit);
}
return b.toString();
}
示例12: deParse
import net.sf.jsqlparser.statement.select.Join; //导入依赖的package包/类
public void deParse(Delete delete) {
buffer.append("DELETE");
if(delete.getTables() != null && delete.getTables().size() > 0){
for( Table table : delete.getTables() ){
buffer.append(" ").append(table.getFullyQualifiedName());
}
}
buffer.append(" FROM ").append(delete.getTable().toString());
if (delete.getJoins() != null) {
for (Join join : delete.getJoins()) {
if (join.isSimple()) {
buffer.append(", ").append(join);
} else {
buffer.append(" ").append(join);
}
}
}
if (delete.getWhere() != null) {
buffer.append(" WHERE ");
delete.getWhere().accept(expressionVisitor);
}
if(delete.getOrderByElements()!=null){
new OrderByDeParser(expressionVisitor, buffer).deParse(delete.getOrderByElements());
}
if (delete.getLimit() != null) {
new LimitDeparser(buffer).deParse(delete.getLimit());
}
}
示例13: visit
import net.sf.jsqlparser.statement.select.Join; //导入依赖的package包/类
@Override
public void visit(PlainSelect plainSelect) {
plainSelect.getFromItem().accept(this);
if (plainSelect.getJoins()!=null) {
for(Iterator<?> joinsIt = plainSelect.getJoins().iterator();joinsIt.hasNext();){
Join join = (Join) joinsIt.next();
join.getRightItem().accept(this);
}
}
if (plainSelect.getWhere() != null) {
plainSelect.getWhere().accept(this);
}
}
示例14: visitJoin
import net.sf.jsqlparser.statement.select.Join; //导入依赖的package包/类
private void visitJoin(Join j) {
if (j.getOnExpression() != null) {
j.getOnExpression().accept(this);
};
if (j.getRightItem() != null) {
j.getRightItem().accept(this);
}
}
示例15: processJoin
import net.sf.jsqlparser.statement.select.Join; //导入依赖的package包/类
/**
* 处理联接语句
*/
protected void processJoin(Join join) {
if (join.getRightItem() instanceof Table) {
Table fromTable = (Table) join.getRightItem();
if (this.tenantHandler.doTableFilter(fromTable.getName())) {
// 过滤退出执行
return;
}
join.setOnExpression(builderExpression(join.getOnExpression(), fromTable));
}
}