Examples of SqlSessionFactory


Examples of org.apache.ibatis.session.SqlSessionFactory

    testInterfaceScan();

    // make sure the configLocation was setup correctly
    // mybatis-config.xml changes the executor from the default SIMPLE type
    SqlSessionFactory sessionFactory = (SqlSessionFactory) applicationContext
        .getBean("sqlSessionFactory");
    assertSame(ExecutorType.REUSE, sessionFactory.getConfiguration().getDefaultExecutorType());
  }
View Full Code Here

Examples of org.apache.ibatis.session.SqlSessionFactory

    factoryBean.setDatabaseIdProvider(null);
    // mapperLocations properties defaults to null
    factoryBean.setDataSource(dataSource);
    factoryBean.setPlugins(new Interceptor[] { executorInterceptor });

    SqlSessionFactory sqlSessionFactory = factoryBean.getObject();

    find(new SqlSessionTemplate(sqlSessionFactory), true);
    assertCommit(); // SqlSesssionTemplate autocommits
    assertSingleConnection();
    assertExecuteCount(1);
View Full Code Here

Examples of org.apache.ibatis.session.SqlSessionFactory

      // config
      SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
      // mapperLocations properties defaults to null
      factoryBean.setDataSource(dataSource);

      SqlSessionFactory sqlSessionFactory = factoryBean.getObject();

      find(new SqlSessionTemplate(sqlSessionFactory), false);
      fail("TestDao's mapper xml should not be loaded");
    } catch (MyBatisSystemException mbse) {
      // unwrap exception so the exact MyBatis exception can be tested
View Full Code Here

Examples of org.apache.ibatis.session.SqlSessionFactory

    setupFactoryBean();

    factoryBean.setConfigLocation(new org.springframework.core.io.ClassPathResource(
        "org/mybatis/spring/mybatis-config.xml"));

    SqlSessionFactory factory = factoryBean.getObject();

    assertEquals(factory.getConfiguration().getEnvironment().getId(), SqlSessionFactoryBean.class.getSimpleName());
    assertSame(factory.getConfiguration().getEnvironment().getDataSource(), dataSource);
    assertSame(factory.getConfiguration().getEnvironment().getTransactionFactory().getClass(),
        org.mybatis.spring.transaction.SpringManagedTransactionFactory.class);

    // properties explicitly set differently than the defaults in the config xml
    assertFalse(factory.getConfiguration().isCacheEnabled());
    assertTrue(factory.getConfiguration().isUseGeneratedKeys());
    assertSame(factory.getConfiguration().getDefaultExecutorType(), org.apache.ibatis.session.ExecutorType.REUSE);

    // for each statement in the xml file: org.mybatis.spring.TestMapper.xxx & xxx
    assertEquals(8, factory.getConfiguration().getMappedStatementNames().size());

    assertEquals(0, factory.getConfiguration().getResultMapNames().size());
    assertEquals(0, factory.getConfiguration().getParameterMapNames().size());
  }
View Full Code Here

Examples of org.apache.ibatis.session.SqlSessionFactory

  public void testFragmentsAreReadWithMapperLocations() throws Exception {
    setupFactoryBean();

    factoryBean.setMapperLocations(new Resource[] { new ClassPathResource("org/mybatis/spring/TestMapper.xml") });

    SqlSessionFactory factory = factoryBean.getObject();

    // one for 'includedSql' and another for 'org.mybatis.spring.TestMapper.includedSql'
    assertEquals(2, factory.getConfiguration().getSqlFragments().size());
  }
View Full Code Here

Examples of org.apache.ibatis.session.SqlSessionFactory

*/
public class StatementLogProcessEnginePlugin extends AbstractProcessEnginePlugin {

  @Override
  public void postInit(ProcessEngineConfigurationImpl processEngineConfiguration) {
    SqlSessionFactory sqlSessionFactory = processEngineConfiguration.getSqlSessionFactory();

    // wrap the SqlSessionFactory using a statement logger
    StatementLogSqlSessionFactory wrappedSessionFactory = new StatementLogSqlSessionFactory(sqlSessionFactory);
    processEngineConfiguration.setSqlSessionFactory(wrappedSessionFactory);

View Full Code Here

Examples of org.apache.ibatis.session.SqlSessionFactory

            throw new IllegalArgumentException("Unsupported statementType: " + endpoint.getStatementType());
        }
    }

    private void doSelectOne(Exchange exchange) throws Exception {
        SqlSessionFactory client = endpoint.getSqlSessionFactory();
        SqlSession session = client.openSession();
        try {
            Object result;
            Object in = exchange.getIn().getBody();
            if (in != null) {
                if (LOG.isTraceEnabled()) {
View Full Code Here

Examples of org.apache.ibatis.session.SqlSessionFactory

            session.close();
        }
    }

    private void doSelectList(Exchange exchange) throws Exception {
        SqlSessionFactory client = endpoint.getSqlSessionFactory();
        SqlSession session = client.openSession();
        try {
            Object result;
            Object in = exchange.getIn().getBody();
            if (in != null) {
                if (LOG.isTraceEnabled()) {
View Full Code Here

Examples of org.apache.ibatis.session.SqlSessionFactory

            session.close();
        }
    }

    private void doInsert(Exchange exchange) throws Exception {
        SqlSessionFactory client = endpoint.getSqlSessionFactory();
        SqlSession session = client.openSession();
        try {
            Object result;
            Object in = exchange.getIn().getBody();
            if (in != null) {
                // lets handle arrays or collections of objects
View Full Code Here

Examples of org.apache.ibatis.session.SqlSessionFactory

            session.close();
        }
    }

    private void doUpdate(Exchange exchange) throws Exception {
        SqlSessionFactory client = endpoint.getSqlSessionFactory();
        SqlSession session = client.openSession();
        try {
            Object result;
            Object in = exchange.getIn().getBody();
            if (in != null) {
                // lets handle arrays or collections of objects
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.