Package com.ibatis.sqlmap.client

Examples of com.ibatis.sqlmap.client.SqlMapClient


    /**
     * Calls insert on the SqlMapClient.
     */
    public void process(Exchange exchange) throws Exception {
        SqlMapClient client = endpoint.getSqlMapClient();
        Object body = exchange.getIn().getBody();
        if (body == null) {
            // must be a poll so lets do a query
            Message msg = exchange.getOut(true);
            if (LOG.isTraceEnabled()) {
                LOG.trace("Querying for list: " + statement);
            }
            List list = client.queryForList(statement);
            msg.setBody(list);
            msg.setHeader(IBatisConstants.IBATIS_STATEMENT_NAME, statement);
        } else {
            // lets handle arrays or collections of objects
            Iterator iter = ObjectHelper.createIterator(body);
            while (iter.hasNext()) {
                Object value = iter.next();
                if (LOG.isTraceEnabled()) {
                    LOG.trace("Inserting: " + value + " using statement: " + statement);
                }
                client.insert(statement, value);
            }
        }
    }
View Full Code Here


    if (ObjectUtils.isEmpty(configLocations)) {
      throw new IllegalArgumentException("At least 1 'configLocation' entry is required");
    }

    SqlMapClient client = null;
    SqlMapConfigParser configParser = new SqlMapConfigParser();
    for (Resource configLocation : configLocations) {
      InputStream is = configLocation.getInputStream();
      try {
        client = configParser.parse(is, properties);
View Full Code Here

public class IbatisPagingItemReaderParameterTests extends AbstractPagingItemReaderParameterTests {

  @Override
  @SuppressWarnings("deprecation")
  protected AbstractPagingItemReader<Foo> getItemReader() throws Exception {
    SqlMapClient sqlMapClient = createSqlMapClient();

    IbatisPagingItemReader<Foo> reader = new IbatisPagingItemReader<Foo>();
    reader.setQueryId("getPagedFoosLimitAndUp");
    reader.setParameterValues(Collections.<String, Object>singletonMap("limit", 2));
    reader.setSqlMapClient(sqlMapClient);
View Full Code Here

    return reader;
  }

  private SqlMapClient createSqlMapClient() throws Exception {
    SqlMapClient client = SqlMapClientBuilder.buildSqlMapClient(new ClassPathResource("ibatis-config.xml", getClass()).getInputStream());
    return client;
  }
View Full Code Here

    assertEquals(ITEM_COUNT, results.size());
    reader.close();
  }

  private IbatisPagingItemReader<Foo> getItemReader() throws Exception {
    SqlMapClient sqlMapClient = createSqlMapClient();

    IbatisPagingItemReader<Foo> reader = new IbatisPagingItemReader<Foo>();
    if ("postgres".equals(System.getProperty("ENVIRONMENT"))) {
      reader.setQueryId("getPagedFoosPostgres");
    } else if ("oracle".equals(System.getProperty("ENVIRONMENT"))) {
View Full Code Here

@SuppressWarnings("deprecation")
public class IbatisPagingItemReaderCommonTests extends AbstractDatabaseItemStreamItemReaderTests {

  @Override
  protected ItemReader<Foo> getItemReader() throws Exception {
    SqlMapClient sqlMapClient = createSqlMapClient();

    IbatisPagingItemReader<Foo> reader = new IbatisPagingItemReader<Foo>();
    reader.setQueryId("getPagedFoos");
    reader.setPageSize(2);
    reader.setSqlMapClient(sqlMapClient);
View Full Code Here

    assertEquals(ITEM_COUNT, results.size());
    reader.close();
  }

  private IbatisPagingItemReader<Foo> getItemReader() throws Exception {
    SqlMapClient sqlMapClient = createSqlMapClient();

    IbatisPagingItemReader<Foo> reader = new IbatisPagingItemReader<Foo>();
    reader.setQueryId("getPagedFoos");
    reader.setPageSize(2);
    reader.setSqlMapClient(sqlMapClient);
View Full Code Here

  private static final Map<String, SqlMapClient> sqlMapClients = new HashMap<String, SqlMapClient>();

  @Override
  protected SqlMapClient buildSqlMapClient(Resource configLocation, Properties properties) throws IOException {
    String configURI = configLocation.getURI().toString();
    SqlMapClient client = sqlMapClients.get(configURI);
    if (client == null) {
      InputStream is = configLocation.getInputStream();
      client = buildSqlMapClient(is, properties);
      sqlMapClients.put(configURI, client);
    }
View Full Code Here

        }
    }
   
    @Test
    public void testAnotherAwfulTableInsert() {
        SqlMapClient sqlMap = getSqlMapClient();
       
        try {
            Anotherawfultable record = new Anotherawfultable();
            record.setId(5);
            record.setSelect("select");
            record.setInsert("insert");
           
            sqlMap.insert("MBGTEST_ANOTHERAWFULTABLE.insert", record);
           
            Anotherawfultable key = new Anotherawfultable();
            key.setId(5);
           
            Anotherawfultable returnedRecord = (Anotherawfultable)
                sqlMap.queryForObject("MBGTEST_ANOTHERAWFULTABLE.selectByPrimaryKey",
                        key);
           
            assertEquals(record.getId(), returnedRecord.getId());
            assertEquals(record.getSelect(), returnedRecord.getSelect());
            assertEquals(record.getInsert(), returnedRecord.getInsert());
View Full Code Here

  }

  @Override
  public void afterPropertiesSet() throws Exception {
    super.afterPropertiesSet();
    SqlMapClient c = (SqlMapClient)getObject();
    if(sqlExecutor != null && c instanceof SqlMapClientImpl) {
      SqlMapClientImpl client = (SqlMapClientImpl)c;
      SqlMapExecutorDelegate delegate = client.getDelegate();
      try {
        ReflectUtil.setFieldValue(delegate, "sqlExecutor", SqlExecutor.class, sqlExecutor);
View Full Code Here

TOP

Related Classes of com.ibatis.sqlmap.client.SqlMapClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.