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


Java ParameterMethod.setObject1方法代码示例

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


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

示例1: testPreparedInsertSql

import com.taobao.tddl.common.jdbc.ParameterMethod; //导入方法依赖的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: testPreparedUpdateSql

import com.taobao.tddl.common.jdbc.ParameterMethod; //导入方法依赖的package包/类
@Test
public void testPreparedUpdateSql() throws SqlParserException {
    String sql = "UPDATE TABLE1 SET ID=? WHERE ID>=? AND ID<=?";
    UpdateNode un = update(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, 3 });
    ParameterContext p3 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 2, 5 });
    currentParameter.put(1, p1);
    currentParameter.put(2, p2);
    currentParameter.put(3, p3);

    Parameters parameterSettings = new Parameters(currentParameter, false);
    un.assignment(parameterSettings);
    un.build();

    TableNode table1 = new TableNode("TABLE1");
    UpdateNode unExpected = table1.update("ID", new Comparable[] { 2 });
    table1.query("ID>=3 AND ID<=5");
    unExpected.build();

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

示例3: testPreparedDeleteSql

import com.taobao.tddl.common.jdbc.ParameterMethod; //导入方法依赖的package包/类
@Test
public void testPreparedDeleteSql() throws SqlParserException {
    String sql = "DELETE FROM TABLE1 WHERE ID>=? AND ID<=?";
    DeleteNode dn = delete(sql);

    Map<Integer, ParameterContext> currentParameter = new HashMap<Integer, ParameterContext>();
    ParameterContext p1 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 0, 3 });
    ParameterContext p2 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, 5 });
    currentParameter.put(1, p1);
    currentParameter.put(2, p2);

    Parameters parameterSettings = new Parameters(currentParameter, false);
    dn.assignment(parameterSettings);
    dn.build();

    TableNode table1 = new TableNode("TABLE1");
    DeleteNode dnExpected = table1.delete();
    table1.query("ID>=3 AND ID<=5");
    dnExpected.build();
    assertEquals(dn, dnExpected);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:22,代码来源:SqlParserTest.java

示例4: testInsert

import com.taobao.tddl.common.jdbc.ParameterMethod; //导入方法依赖的package包/类
@Test
public void testInsert() {
    String sql = "INSERT INTO TABLE1(ID) VALUES(?)";

    Map<Integer, ParameterContext> currentParameter = new HashMap<Integer, ParameterContext>();
    ParameterContext p1 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 2 });
    currentParameter.put(1, p1);

    Parameters parameterSettings = new Parameters();
    parameterSettings.getCurrentParameter().put(1,
        new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, 1 }));
    parameterSettings.addBatch();

    parameterSettings.getCurrentParameter().put(1,
        new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, 2 }));
    parameterSettings.addBatch();

    IDataNodeExecutor plan = optimizer.optimizeAndAssignment(sql, parameterSettings, null, false);
    Assert.assertTrue(plan instanceof IMerge);
    Assert.assertEquals(((IInsert) ((IMerge) plan).getSubNodes().get(0)).getBatchIndexs(), Arrays.asList(0));
    Assert.assertEquals(((IInsert) ((IMerge) plan).getSubNodes().get(1)).getBatchIndexs(), Arrays.asList(1));
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:23,代码来源:BatchTest.java

示例5: TABLE7

import com.taobao.tddl.common.jdbc.ParameterMethod; //导入方法依赖的package包/类
@Test
public void testInsert_广播表() {
    String sql = "INSERT INTO TABLE7(ID) VALUES(?)";

    Map<Integer, ParameterContext> currentParameter = new HashMap<Integer, ParameterContext>();
    ParameterContext p1 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 2 });
    currentParameter.put(1, p1);

    Parameters parameterSettings = new Parameters();
    parameterSettings.getCurrentParameter().put(1,
        new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, 1 }));
    parameterSettings.addBatch();

    parameterSettings.getCurrentParameter().put(1,
        new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, 2 }));
    parameterSettings.addBatch();

    IDataNodeExecutor plan = optimizer.optimizeAndAssignment(sql, parameterSettings, null, false);
    Assert.assertTrue(plan instanceof IMerge);
    Assert.assertEquals(4, ((IMerge) plan).getSubNodes().size());
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:22,代码来源:BatchTest.java

示例6: AUTOINC

import com.taobao.tddl.common.jdbc.ParameterMethod; //导入方法依赖的package包/类
@Test
public void testInsert_自增id() {
    String sql = "INSERT INTO AUTOINC(NAME) VALUES(?)";

    Map<Integer, ParameterContext> currentParameter = new HashMap<Integer, ParameterContext>();
    ParameterContext p1 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 2 });
    currentParameter.put(1, p1);

    Parameters parameterSettings = new Parameters();
    parameterSettings.getCurrentParameter().put(1,
        new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, "hello1" }));
    parameterSettings.addBatch();

    parameterSettings.getCurrentParameter().put(1,
        new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, "hello2" }));
    parameterSettings.addBatch();

    IDataNodeExecutor plan = optimizer.optimizeAndAssignment(sql, parameterSettings, null, false);
    Assert.assertTrue(plan instanceof IMerge);
    Assert.assertEquals(((IInsert) ((IMerge) plan).getSubNodes().get(0)).getBatchIndexs(), Arrays.asList(0));
    Assert.assertEquals(((IInsert) ((IMerge) plan).getSubNodes().get(1)).getBatchIndexs(), Arrays.asList(1));
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:23,代码来源:BatchTest.java

示例7: STUDENT

import com.taobao.tddl.common.jdbc.ParameterMethod; //导入方法依赖的package包/类
@Test
public void testInsert_单库单表() {
    String sql = "INSERT INTO STUDENT(ID) VALUES(?)";

    Map<Integer, ParameterContext> currentParameter = new HashMap<Integer, ParameterContext>();
    ParameterContext p1 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 2 });
    currentParameter.put(1, p1);

    Parameters parameterSettings = new Parameters();
    parameterSettings.getCurrentParameter().put(1,
        new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, 1 }));
    parameterSettings.addBatch();

    parameterSettings.getCurrentParameter().put(1,
        new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, 2 }));
    parameterSettings.addBatch();

    IDataNodeExecutor plan = optimizer.optimizeAndAssignment(sql, parameterSettings, null, false);
    Assert.assertTrue(plan instanceof IInsert);
    Assert.assertEquals(((IInsert) plan).getBatchIndexs(), Arrays.asList(0, 1));
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:22,代码来源:BatchTest.java

示例8: testPut

import com.taobao.tddl.common.jdbc.ParameterMethod; //导入方法依赖的package包/类
@Test
public void testPut() {
    String sql = "REPLACE INTO TABLE1(ID) VALUES(?)";

    Map<Integer, ParameterContext> currentParameter = new HashMap<Integer, ParameterContext>();
    ParameterContext p1 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 2 });
    currentParameter.put(1, p1);

    Parameters parameterSettings = new Parameters();
    parameterSettings.getCurrentParameter().put(1,
        new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, 1 }));
    parameterSettings.addBatch();

    parameterSettings.getCurrentParameter().put(1,
        new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, 2 }));
    parameterSettings.addBatch();

    IDataNodeExecutor plan = optimizer.optimizeAndAssignment(sql, parameterSettings, null, false);
    Assert.assertTrue(plan instanceof IMerge);
    Assert.assertEquals(((IReplace) ((IMerge) plan).getSubNodes().get(0)).getBatchIndexs(), Arrays.asList(0));
    Assert.assertEquals(((IReplace) ((IMerge) plan).getSubNodes().get(1)).getBatchIndexs(), Arrays.asList(1));
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:23,代码来源:BatchTest.java

示例9: testUpdate

import com.taobao.tddl.common.jdbc.ParameterMethod; //导入方法依赖的package包/类
@Test
public void testUpdate() {
    String sql = "UPDATE TABLE1 SET NAME = ? WHERE ID = ?";

    Map<Integer, ParameterContext> currentParameter = new HashMap<Integer, ParameterContext>();
    ParameterContext p1 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 2 });
    currentParameter.put(1, p1);

    Parameters parameterSettings = new Parameters();
    parameterSettings.getCurrentParameter().put(1,
        new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, "hello1" }));
    parameterSettings.getCurrentParameter().put(2,
        new ParameterContext(ParameterMethod.setObject1, new Object[] { 2, 1 }));
    parameterSettings.addBatch();

    parameterSettings.getCurrentParameter().put(1,
        new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, "hello2" }));
    parameterSettings.getCurrentParameter().put(2,
        new ParameterContext(ParameterMethod.setObject1, new Object[] { 2, 2 }));
    parameterSettings.addBatch();

    IDataNodeExecutor plan = optimizer.optimizeAndAssignment(sql, parameterSettings, null, false);
    Assert.assertTrue(plan instanceof IMerge);
    Assert.assertEquals(((IUpdate) ((IMerge) plan).getSubNodes().get(0)).getBatchIndexs(), Arrays.asList(0));
    Assert.assertEquals(((IUpdate) ((IMerge) plan).getSubNodes().get(1)).getBatchIndexs(), Arrays.asList(1));
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:27,代码来源:BatchTest.java

示例10: testDelete

import com.taobao.tddl.common.jdbc.ParameterMethod; //导入方法依赖的package包/类
@Test
public void testDelete() {
    String sql = "DELETE FROM TABLE1 WHERE ID = ?";

    Map<Integer, ParameterContext> currentParameter = new HashMap<Integer, ParameterContext>();
    ParameterContext p1 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 2 });
    currentParameter.put(1, p1);

    Parameters parameterSettings = new Parameters();
    parameterSettings.getCurrentParameter().put(1,
        new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, 1 }));
    parameterSettings.addBatch();

    parameterSettings.getCurrentParameter().put(1,
        new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, 2 }));
    parameterSettings.addBatch();

    IDataNodeExecutor plan = optimizer.optimizeAndAssignment(sql, parameterSettings, null, false);
    Assert.assertTrue(plan instanceof IMerge);
    Assert.assertEquals(((IDelete) ((IMerge) plan).getSubNodes().get(0)).getBatchIndexs(), Arrays.asList(0));
    Assert.assertEquals(((IDelete) ((IMerge) plan).getSubNodes().get(1)).getBatchIndexs(), Arrays.asList(1));
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:23,代码来源:BatchTest.java

示例11: testPreparedDeleteSql

import com.taobao.tddl.common.jdbc.ParameterMethod; //导入方法依赖的package包/类
@Test
public void testPreparedDeleteSql() throws SqlParserException, QueryException {
    String sql = "DELETE FROM TABLE1 WHERE ID>=? AND ID<=?";
    DeleteNode dn = delete(sql);

    Map<Integer, ParameterContext> parameterSettings = null;
    parameterSettings = new TreeMap<Integer, ParameterContext>();
    ParameterContext p1 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 0, 3 });
    ParameterContext p2 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, 5 });
    parameterSettings.put(1, p1);
    parameterSettings.put(2, p2);

    dn.assignment(parameterSettings);
    dn.build();

    TableNode table1 = new TableNode("TABLE1");
    DeleteNode dnExpected = table1.delete();
    table1.query("ID>=3 AND ID<=5");
    dnExpected.build();
    assertEquals(dn, dnExpected);
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:22,代码来源:SqlParserTest.java

示例12: testPreparedUpdateSql

import com.taobao.tddl.common.jdbc.ParameterMethod; //导入方法依赖的package包/类
@Test
public void testPreparedUpdateSql() throws SqlParserException, QueryException {
    String sql = "UPDATE TABLE1 SET ID=? WHERE ID>=? AND ID<=?";
    UpdateNode un = update(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, 3 });
    ParameterContext p3 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 2, 5 });
    parameterSettings.put(1, p1);
    parameterSettings.put(2, p2);
    parameterSettings.put(3, p3);

    un.assignment(parameterSettings);
    un.build();

    TableNode table1 = new TableNode("TABLE1");
    UpdateNode unExpected = table1.update("ID", new Comparable[] { 2 });
    table1.query("ID>=3 AND ID<=5");
    unExpected.build();

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

示例13: convert

import com.taobao.tddl.common.jdbc.ParameterMethod; //导入方法依赖的package包/类
protected Parameters convert(List<Object> args) {
    Map<Integer, ParameterContext> map = new HashMap<Integer, ParameterContext>(args.size());
    int index = 1;
    for (Object obj : args) {
        ParameterContext context = new ParameterContext(ParameterMethod.setObject1, new Object[] { index, obj });
        map.put(index, context);
        index++;
    }
    return new Parameters(map, false);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:11,代码来源:BaseOptimizerTest.java

示例14: ParameterContext

import com.taobao.tddl.common.jdbc.ParameterMethod; //导入方法依赖的package包/类
@Test
public void testUpdate_范围查询() {
    String sql = "UPDATE TABLE1 SET NAME = ? WHERE ID > ? AND ID < ?";

    Map<Integer, ParameterContext> currentParameter = new HashMap<Integer, ParameterContext>();
    ParameterContext p1 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 2 });
    currentParameter.put(1, p1);

    Parameters parameterSettings = new Parameters();
    parameterSettings.getCurrentParameter().put(1,
        new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, "hello1" }));
    parameterSettings.getCurrentParameter().put(2,
        new ParameterContext(ParameterMethod.setObject1, new Object[] { 2, 1 }));
    parameterSettings.getCurrentParameter().put(3,
        new ParameterContext(ParameterMethod.setObject1, new Object[] { 3, 4 }));
    parameterSettings.addBatch();

    parameterSettings.getCurrentParameter().put(1,
        new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, "hello2" }));
    parameterSettings.getCurrentParameter().put(2,
        new ParameterContext(ParameterMethod.setObject1, new Object[] { 2, 2 }));
    parameterSettings.getCurrentParameter().put(3,
        new ParameterContext(ParameterMethod.setObject1, new Object[] { 3, 5 }));
    parameterSettings.addBatch();

    IDataNodeExecutor plan = optimizer.optimizeAndAssignment(sql, parameterSettings, null, false);
    Assert.assertTrue(plan instanceof IMerge);
    Assert.assertEquals(((IUpdate) ((IMerge) plan).getSubNodes().get(0)).getBatchIndexs(), Arrays.asList(0));
    Assert.assertEquals(((IUpdate) ((IMerge) plan).getSubNodes().get(1)).getBatchIndexs(), Arrays.asList(1));
    Assert.assertEquals(((IUpdate) ((IMerge) plan).getSubNodes().get(2)).getBatchIndexs(), Arrays.asList(0, 1));
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:32,代码来源:BatchTest.java

示例15: IN

import com.taobao.tddl.common.jdbc.ParameterMethod; //导入方法依赖的package包/类
@Test
public void testUpdate_in查询() {
    String sql = "UPDATE TABLE1 SET NAME = ? WHERE ID IN (?,?)";

    Map<Integer, ParameterContext> currentParameter = new HashMap<Integer, ParameterContext>();
    ParameterContext p1 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 2 });
    currentParameter.put(1, p1);

    Parameters parameterSettings = new Parameters();
    parameterSettings.getCurrentParameter().put(1,
        new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, "hello1" }));
    parameterSettings.getCurrentParameter().put(2,
        new ParameterContext(ParameterMethod.setObject1, new Object[] { 2, 2 }));
    parameterSettings.getCurrentParameter().put(3,
        new ParameterContext(ParameterMethod.setObject1, new Object[] { 3, 3 }));
    parameterSettings.addBatch();

    parameterSettings.getCurrentParameter().put(1,
        new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, "hello2" }));
    parameterSettings.getCurrentParameter().put(2,
        new ParameterContext(ParameterMethod.setObject1, new Object[] { 2, 3 }));
    parameterSettings.getCurrentParameter().put(3,
        new ParameterContext(ParameterMethod.setObject1, new Object[] { 3, 4 }));
    parameterSettings.addBatch();

    IDataNodeExecutor plan = optimizer.optimizeAndAssignment(sql, parameterSettings, null, false);
    Assert.assertTrue(plan instanceof IMerge);
    Assert.assertEquals(((IUpdate) ((IMerge) plan).getSubNodes().get(0)).getBatchIndexs(), Arrays.asList(0));
    Assert.assertEquals(((IUpdate) ((IMerge) plan).getSubNodes().get(1)).getBatchIndexs(), Arrays.asList(1));
    Assert.assertEquals(((IUpdate) ((IMerge) plan).getSubNodes().get(2)).getBatchIndexs(), Arrays.asList(0, 1));
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:32,代码来源:BatchTest.java


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