本文整理汇总了Java中net.sf.jsqlparser.schema.Table类的典型用法代码示例。如果您正苦于以下问题:Java Table类的具体用法?Java Table怎么用?Java Table使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Table类属于net.sf.jsqlparser.schema包,在下文中一共展示了Table类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import net.sf.jsqlparser.schema.Table; //导入依赖的package包/类
@Override
public void visit(Column tableColumn) {
final Table table = tableColumn.getTable();
String tableName = null;
if (table != null) {
if (table.getAlias() != null) {
tableName = table.getAlias().getName();
} else {
tableName = table.getFullyQualifiedName();
}
}
if (tableName != null && !tableName.isEmpty()) {
buffer.append(tableName).append(".");
}
buffer.append(tableColumn.getColumnName());
}
示例2: addJoin
import net.sf.jsqlparser.schema.Table; //导入依赖的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);
}
示例3: visit
import net.sf.jsqlparser.schema.Table; //导入依赖的package包/类
@Override
public void visit(Update update) {
for (Table table : update.getTables()) {
tables.add(table.getName());
}
if (update.getExpressions() != null) {
for (Expression expression : update.getExpressions()) {
expression.accept(this);
}
}
if (update.getFromItem() != null) {
update.getFromItem().accept(this);
}
if (update.getJoins() != null) {
for (Join join : update.getJoins()) {
join.getRightItem().accept(this);
}
}
if (update.getWhere() != null) {
update.getWhere().accept(this);
}
}
示例4: visit
import net.sf.jsqlparser.schema.Table; //导入依赖的package包/类
@Override
public void visit(Update update) {
for (Table table : update.getTables()) {
tables.add(table, table1 -> table.getName());
}
if (update.getExpressions() != null) {
for (Expression expression : update.getExpressions()) {
expression.accept(this);
}
}
if (update.getFromItem() != null) {
update.getFromItem().accept(this);
}
if (update.getJoins() != null) {
for (Join join : update.getJoins()) {
join.getRightItem().accept(this);
}
}
if (update.getWhere() != null) {
update.getWhere().accept(this);
}
}
示例5: JoinVisitor
import net.sf.jsqlparser.schema.Table; //导入依赖的package包/类
JoinVisitor(String queryId, net.sf.jsqlparser.statement.Statement statement)
{
this.queryId = queryId;
this.statement = statement;
if (statement instanceof Select)
{
SelectDeParser deparser = new SelectDeParser()
{
@Override
public void visit(Table table)
{
if (table.getAlias() != null && !table.getAlias().getName().equals(""))
aliases.put(table.getAlias().getName().toLowerCase(), table.getName().toLowerCase());
}
};
((Select)statement).getSelectBody().accept(deparser);
}
}
示例6: visit
import net.sf.jsqlparser.schema.Table; //导入依赖的package包/类
@Override
public void visit(Update update) {
if (enableLimitCheck && update.getLimit() == null) {
throw new IllegalStateException("no limit in sql: " + sql);
}
this.getStack().push(new FrameContext());
if (update.getTables() != null) {
for (Table table : update.getTables()) {
ShardRouteConfig routeConfig = shardRouter.getRouteConfig(table.getSchemaName(), table.getName());
if (routeConfig != null) {
TableWrapper tab = new TableWrapper(table, routeConfig);
addRoutedTableIntoContext(tab, routeConfig, true);
}
}
}
super.visit(update);
afterVisitBaseStatement();
}
示例7: visit
import net.sf.jsqlparser.schema.Table; //导入依赖的package包/类
@Override
public void visit(Table tableName) {
if (tableName == null) {
return;
}
String name = tableName.getName();
if (name != null) {
tableName.setName(CompatibilityUtils.fixMySqlName(name.toLowerCase()));
}
Alias alias = tableName.getAlias();
if (alias != null) {
String aliasName = alias.getName();
if (aliasName != null) {
alias.setName(CompatibilityUtils.fixMySqlName(aliasName.toLowerCase()));
}
}
}
示例8: processPlainSelect
import net.sf.jsqlparser.schema.Table; //导入依赖的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());
}
}
}
示例9: builderExpression
import net.sf.jsqlparser.schema.Table; //导入依赖的package包/类
/**
* 处理条件
*/
protected Expression builderExpression(Expression expression, Table table) {
//生成字段名
EqualsTo equalsTo = new EqualsTo();
equalsTo.setLeftExpression(this.getAliasColumn(table));
equalsTo.setRightExpression(tenantHandler.getTenantId());
//加入判断防止条件为空时生成 "and null" 导致查询结果为空
if (expression == null) {
return equalsTo;
} else {
if (expression instanceof BinaryExpression) {
BinaryExpression binaryExpression = (BinaryExpression) expression;
if (binaryExpression.getLeftExpression() instanceof FromItem) {
processFromItem((FromItem) binaryExpression.getLeftExpression());
}
if (binaryExpression.getRightExpression() instanceof FromItem) {
processFromItem((FromItem) binaryExpression.getRightExpression());
}
}
return new AndExpression(equalsTo, expression);
}
}
示例10: checkTableEntitlement
import net.sf.jsqlparser.schema.Table; //导入依赖的package包/类
private void checkTableEntitlement(CallingContext context, StatementType statementType, final Table table) {
String entitlementPath = getEntitlementPath(statementType);
log.debug(String.format("check %s entitlement %s on table %s", statementType, entitlementPath, table.getFullyQualifiedName()));
Kernel.getKernel().validateContext(context, entitlementPath, new IEntitlementsContext() {
@Override
public String getDocPath() {
return table.getName();
}
@Override
public String getAuthority() {
return StringUtils.isBlank(table.getSchemaName()) ? schema : table.getSchemaName();
}
@Override
public String getFullPath() {
return String.format("%s/%s", getAuthority(), table.getName());
}
});
}
示例11: TableWithAlias
import net.sf.jsqlparser.schema.Table; //导入依赖的package包/类
final public Table TableWithAlias() throws ParseException {
Table table = null;
String alias = null;
table = Table();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case K_AS:
case K_KEY:
case K_END:
case K_BEGIN:
case S_IDENTIFIER:
case S_QUOTED_IDENTIFIER:
alias = Alias();
table.setAlias(alias);
break;
default:
jj_la1[22] = jj_gen;
;
}
{if (true) return table;}
throw new Error("Missing return statement in function");
}
示例12: IntoClause
import net.sf.jsqlparser.schema.Table; //导入依赖的package包/类
final public void IntoClause() throws ParseException {
jj_consume_token(K_INTO);
Table();
label_11:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 79:
;
break;
default:
jj_la1[57] = jj_gen;
break label_11;
}
jj_consume_token(79);
Table();
}
}
示例13: testUnion
import net.sf.jsqlparser.schema.Table; //导入依赖的package包/类
public void testUnion() throws JSQLParserException {
String statement =
"SELECT * FROM mytable WHERE mytable.col = 9 UNION "
+ "SELECT * FROM mytable3 WHERE mytable3.col = ? UNION "
+ "SELECT * FROM mytable2 LIMIT 3,4";
Union union = (Union) ((Select) parserManager.parse(new StringReader(statement))).getSelectBody();
assertEquals(3, union.getPlainSelects().size());
assertEquals("mytable", ((Table) ((PlainSelect) union.getPlainSelects().get(0)).getFromItem()).getName());
assertEquals("mytable3", ((Table) ((PlainSelect) union.getPlainSelects().get(1)).getFromItem()).getName());
assertEquals("mytable2", ((Table) ((PlainSelect) union.getPlainSelects().get(2)).getFromItem()).getName());
assertEquals(3, ((PlainSelect) union.getPlainSelects().get(2)).getLimit().getOffset());
//use brakets for toString
//use standard limit syntax
String statementToString =
"(SELECT * FROM mytable WHERE mytable.col = 9) UNION "
+ "(SELECT * FROM mytable3 WHERE mytable3.col = ?) UNION "
+ "(SELECT * FROM mytable2 LIMIT 4 OFFSET 3)";
assertEquals(statementToString, ""+union);
}
示例14: parse
import net.sf.jsqlparser.schema.Table; //导入依赖的package包/类
public Set<String> parse(Delete delete) {
Set<String> tableSet = new HashSet<String>();
if (delete != null) {
Table table = delete.getTable();
if (table != null) {
tableSet.add(table.getName());
}
Expression expression = delete.getWhere();
if (expression != null) {
tableSet.addAll(parseExpression(expression));
}
}
return tableSet;
}
示例15: parse
import net.sf.jsqlparser.schema.Table; //导入依赖的package包/类
public Set<String> parse(Update update) {
Set<String> tableSet = new HashSet<String>();
if (update != null) {
List<Table> tables = update.getTables();
for (Table table : tables) {
tableSet.add(table.getName());
}
Expression expression = update.getWhere();
if (expression != null) {
tableSet.addAll(parseExpression(expression));
}
}
return tableSet;
}