當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。