当前位置: 首页>>代码示例>>Java>>正文


Java TableNode.insert方法代码示例

本文整理汇总了Java中com.taobao.tddl.optimizer.core.ast.query.TableNode.insert方法的典型用法代码示例。如果您正苦于以下问题:Java TableNode.insert方法的具体用法?Java TableNode.insert怎么用?Java TableNode.insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.taobao.tddl.optimizer.core.ast.query.TableNode的用法示例。


在下文中一共展示了TableNode.insert方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testPreparedInsertSql

import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Test
public void testPreparedInsertSql() throws SqlParserException {
    String sql = "INSERT INTO TABLE1(ID,NAME,SCHOOL) VALUES (?, ?, ?)";
    InsertNode in = insert(sql);
    Map<Integer, ParameterContext> currentParameter = new HashMap<Integer, ParameterContext>();
    ParameterContext p1 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 0, 2 });
    ParameterContext p2 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, "sun" });
    ParameterContext p3 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 2, "sysu" });
    currentParameter.put(1, p1);
    currentParameter.put(2, p2);
    currentParameter.put(3, p3);
    Parameters parameterSettings = new Parameters(currentParameter, false);

    in.build();
    in.assignment(parameterSettings);

    TableNode table1 = new TableNode("TABLE1");
    InsertNode inExpected = table1.insert("ID NAME SCHOOL", new Comparable[] { 2, "sun", "sysu" });
    inExpected.build();
    assertEquals(in, inExpected);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:22,代码来源:SqlParserTest.java

示例2: visit

import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
public void visit(DMLInsertStatement node) {
    TableNode table = getTableNode(node);
    String insertColumns = this.getInsertColumnsStr(node);
    List<RowExpression> exprList = node.getRowList();
    if (exprList != null && exprList.size() == 1) {
        RowExpression expr = exprList.get(0);
        Comparable[] iv = getRowValue(expr);
        this.insertNode = table.insert(insertColumns, iv);
    } else {
        throw new NotSupportException("could not support multi row values.");
    }

    // 暂时不支持子表的查询
    QueryExpression subQuery = node.getSelect();
    if (subQuery != null) {
        throw new NotSupportException("could not support insert into select");
    }
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:19,代码来源:MySqlInsertVisitor.java

示例3: testPreparedInsertSql

import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Test
public void testPreparedInsertSql() throws SqlParserException, QueryException {
    String sql = "INSERT INTO TABLE1(ID,NAME,SCHOOL) VALUES (?, ?, ?)";
    InsertNode in = insert(sql);
    Map<Integer, ParameterContext> parameterSettings = null;
    parameterSettings = new TreeMap<Integer, ParameterContext>();
    ParameterContext p1 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 0, 2 });
    ParameterContext p2 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, "sun" });
    ParameterContext p3 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 2, "sysu" });
    parameterSettings.put(1, p1);
    parameterSettings.put(2, p2);
    parameterSettings.put(3, p3);

    in.assignment(parameterSettings);
    in.build();

    TableNode table1 = new TableNode("TABLE1");
    InsertNode inExpected = table1.insert("ID NAME SCHOOL", new Comparable[] { 2, "sun", "sysu" });
    inExpected.build();
    assertEquals(in, inExpected);
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:22,代码来源:SqlParserTest.java

示例4: visit

import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Override
public void visit(CreateSequence node) {
    TableNode table = getTableNode();
    String insertColumns = this.getInsertColumnsStr();

    Object[] iv = getRowValue(node);
    this.createSequenceInsert = table.insert(insertColumns, iv);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:9,代码来源:SequenceVisitor.java

示例5: TABLE1

import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Test
public void testInsert_无字段() throws SqlParserException {
    String sql = "INSERT INTO TABLE1(ID) VALUES (2)";
    InsertNode in = insert(sql);
    in.build();

    TableNode table1 = new TableNode("TABLE1");
    InsertNode inExpected = table1.insert("ID", new Comparable[] { 2 });
    inExpected.build();

    assertEquals(in, inExpected);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:13,代码来源:SqlParserTest.java

示例6: testInsert

import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Test
public void testInsert() {
    TableNode table = new TableNode("TABLE1");
    Comparable values[] = { 2 };
    InsertNode insert = table.insert("ID", values);
    IDataNodeExecutor plan = optimizer.optimizeAndAssignment(insert, null, null);
    Assert.assertTrue(plan instanceof IInsert);

    String sql = "INSERT INTO TABLE1(ID) VALUES(2)";
    plan = optimizer.optimizeAndAssignment(sql, null, null, false);
    Assert.assertTrue(plan instanceof IInsert);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:13,代码来源:DMLNodeChooserTest.java

示例7: TableNode

import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Test
public void testInsert_广播表() {
    TableNode table = new TableNode("TABLE7");
    Comparable values[] = { 2 };
    InsertNode insert = table.insert("ID", values);
    IDataNodeExecutor plan = optimizer.optimizeAndAssignment(insert, null, null);
    Assert.assertTrue(plan instanceof IMerge);
    Assert.assertEquals(4, ((IMerge) plan).getSubNodes().size());

    String sql = "INSERT INTO TABLE7(ID) VALUES(2)";
    plan = optimizer.optimizeAndAssignment(sql, null, null, false);
    Assert.assertTrue(plan instanceof IMerge);
    Assert.assertEquals(4, ((IMerge) plan).getSubNodes().size());
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:15,代码来源:DMLNodeChooserTest.java

示例8: TABLE1

import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Test
public void testInsert_无字段() throws SqlParserException, QueryException {
    String sql = "INSERT INTO TABLE1(ID) VALUES (2)";
    InsertNode in = insert(sql);
    in.build();

    TableNode table1 = new TableNode("TABLE1");
    InsertNode inExpected = table1.insert("ID", new Comparable[] { 2 });
    inExpected.build();

    assertEquals(in, inExpected);
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:13,代码来源:SqlParserTest.java

示例9: testInsert

import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Test
public void testInsert() throws QueryException {
    TableNode table = new TableNode("TABLE1");
    Comparable values[] = { 2 };
    InsertNode insert = table.insert("ID", values);
    IDataNodeExecutor plan = optimizer.optimizeAndAssignment(insert, null, null);
    Assert.assertTrue(plan instanceof IInsert);

    String sql = "INSERT INTO TABLE1(ID) VALUES(2)";
    plan = optimizer.optimizeAndAssignment(sql, null, null, false);
    Assert.assertTrue(plan instanceof IInsert);
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:13,代码来源:DMLNodeChooserTest.java

示例10: TableNode

import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Test
public void testInsert_全字段() throws QueryException {
    TableNode table = new TableNode("TABLE1");
    Comparable values[] = { 2, "sysu", "sun" };
    InsertNode insert = table.insert("ID SCHOOL NAME", values);
    IDataNodeExecutor plan = optimizer.optimizeAndAssignment(insert, null, null);
    Assert.assertTrue(plan instanceof IInsert);

    String sql = "INSERT INTO TABLE1 VALUES(2,'sysu','sun')";
    plan = optimizer.optimizeAndAssignment(sql, null, null, false);
    Assert.assertTrue(plan instanceof IInsert);
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:13,代码来源:DMLNodeChooserTest.java


注:本文中的com.taobao.tddl.optimizer.core.ast.query.TableNode.insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。