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


Java Configuration.addMapper方法代码示例

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


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

示例1: createSqlSessionManager

import org.apache.ibatis.session.Configuration; //导入方法依赖的package包/类
/**
 * This method creates the sqlSessionManager of myBatis. It integrates all the SQL mappers
 *
 * @return a {@link SqlSessionFactory}
 */
private SqlSessionManager createSqlSessionManager() {
    Environment environment = new Environment(DEFAULT, this.transactionFactory,
        taskanaEngineConfiguration.getDatasource());
    Configuration configuration = new Configuration(environment);
    // add mappers
    configuration.addMapper(TaskMapper.class);
    configuration.addMapper(TaskMonitorMapper.class);
    configuration.addMapper(WorkbasketMapper.class);
    configuration.addMapper(DistributionTargetMapper.class);
    configuration.addMapper(ClassificationMapper.class);
    configuration.addMapper(WorkbasketAccessMapper.class);
    configuration.addMapper(ObjectReferenceMapper.class);
    configuration.addMapper(QueryMapper.class);
    configuration.addMapper(AttachmentMapper.class);
    configuration.getTypeHandlerRegistry().register(MapTypeHandler.class);
    SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(configuration);
    SqlSessionManager sessionManager = SqlSessionManager.newInstance(sessionFactory);
    return sessionManager;
}
 
开发者ID:Taskana,项目名称:taskana,代码行数:25,代码来源:TaskanaEngineImpl.java

示例2: getSqlSessionFactory

import org.apache.ibatis.session.Configuration; //导入方法依赖的package包/类
private SqlSessionFactory getSqlSessionFactory(DataSource dataSource) {
    TransactionFactory transactionFactory = new JdbcTransactionFactory();
    Environment environment = new Environment("development", transactionFactory, dataSource);
    Configuration configuration = new Configuration(environment);

    configuration.addMapper(UsersDAO.class);

    return new SqlSessionFactoryBuilder().build(configuration);
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_06,代码行数:10,代码来源:MainAnnotationsExample.java

示例3: setUp

import org.apache.ibatis.session.Configuration; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception{
    setupSqlSessionFactory("com/eyougo/mybatis/postgis/type/LineStringTypeHandlerTest.sql");
    Configuration configuration = sqlSessionFactory.getConfiguration();
    configuration.getTypeHandlerRegistry().register(LineStringTypeHandler.class);
    configuration.addMapper(LineStringMapper.class);
}
 
开发者ID:eyougo,项目名称:mybatis-typehandlers-postgis,代码行数:8,代码来源:LineStringTypeHandlerTest.java

示例4: setUp

import org.apache.ibatis.session.Configuration; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception{
    setupSqlSessionFactory("com/eyougo/mybatis/postgis/type/PolygonTypeHandlerTest.sql");
    Configuration configuration = sqlSessionFactory.getConfiguration();
    configuration.getTypeHandlerRegistry().register(PolygonTypeHandler.class);
    configuration.addMapper(PolygonMapper.class);
}
 
开发者ID:eyougo,项目名称:mybatis-typehandlers-postgis,代码行数:8,代码来源:PolygonTypeHandlerTest.java

示例5: setUp

import org.apache.ibatis.session.Configuration; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception{
    setupSqlSessionFactory("com/eyougo/mybatis/postgis/type/PointTypeHandlerTest.sql");
    Configuration configuration = sqlSessionFactory.getConfiguration();
    configuration.getTypeHandlerRegistry().register(PointTypeHandler.class);
    configuration.addMapper(PointMapper.class);
}
 
开发者ID:eyougo,项目名称:mybatis-typehandlers-postgis,代码行数:8,代码来源:PointTypeHandlerTest.java

示例6: setUp

import org.apache.ibatis.session.Configuration; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception{
    setupSqlSessionFactory("com/eyougo/mybatis/postgis/type/MultiPointTypeHandlerTest.sql");
    Configuration configuration = sqlSessionFactory.getConfiguration();
    configuration.getTypeHandlerRegistry().register(MultiPointTypeHandler.class);
    configuration.addMapper(MultiPointMapper.class);
}
 
开发者ID:eyougo,项目名称:mybatis-typehandlers-postgis,代码行数:8,代码来源:MultiPointTypeHandlerTest.java

示例7: doTest

import org.apache.ibatis.session.Configuration; //导入方法依赖的package包/类
@Test
public void doTest() {
	HikariDataSource dataSource = new HikariDataSource();// DataSource

	// H2 is a memory database
	dataSource.setDriverClassName("org.h2.Driver");
	dataSource.setJdbcUrl("jdbc:h2:mem:DBName;MODE=MYSQL;DB_CLOSE_DELAY=-1;TRACE_LEVEL_SYSTEM_OUT=0");
	dataSource.setUsername("sa");
	dataSource.setPassword("");

	// MySQL
	// dataSource.setDriverClassName("com.mysql.jdbc.Driver");
	// dataSource.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/test?rewriteBatchedStatements=true&useSSL=false");
	// dataSource.setUsername("root");
	// dataSource.setPassword("root888");

	// MS-SqlServer
	// dataSource.setDriverClassName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
	// dataSource.setJdbcUrl("jdbc:sqlserver://localhost:1433;databaseName=test");
	// dataSource.setUsername("sa");
	// dataSource.setPassword("root888");

	// ORACLE
	// dataSource.setDriverClassName("oracle.jdbc.OracleDriver");
	// dataSource.setJdbcUrl("jdbc:oracle:thin:@127.0.0.1:1521:XE");
	// dataSource.setUsername("root");
	// dataSource.setPassword("root888");

	SqlBoxContext ctx = new SqlBoxContext(dataSource);
	SqlBoxContext.setDefaultContext(ctx);
	ctx.setAllowShowSQL(true);
	String[] ddlArray = ctx.toDropAndCreateDDL(User.class);
	for (String ddl : ddlArray)
		ctx.quiteExecute(ddl);
	for (int i = 1; i <= 100; i++)
		new User().put("firstName", "Foo" + i, "lastName", "Bar" + i, "age", i).insert();

	TransactionFactory transactionFactory = new JdbcTransactionFactory();
	Environment environment = new Environment("demo", transactionFactory, dataSource);
	Configuration configuration = new Configuration(environment);
	configuration.addMapper(UserMapper.class);
	SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(configuration);
	configuration.addInterceptor(new JDialectsPlugin());

	SqlSession session = null;
	try {
		session = sqlSessionFactory.openSession();
		Connection conn = session.getConnection();
		Assert.assertEquals(100, ctx.nQueryForLongValue(conn, "select count(*) from users"));

		List<Map<String, Object>> users;
		try {
			paginInfo.set(new Object[] { ctx.getDialect(), 3, 10 });
			users = session.getMapper(UserMapper.class).getOlderThan(50);
		} finally {
			paginInfo.remove();
		}
		Assert.assertEquals(10, users.size());
		for (Map<String, Object> map : users)
			System.out.println("UserName=" + map.get("USERNAME") + ", age=" + map.get("AGE"));
	} finally {
		session.close();
	}
	dataSource.close();
}
 
开发者ID:drinkjava2,项目名称:jDialects,代码行数:66,代码来源:Demo.java

示例8: main

import org.apache.ibatis.session.Configuration; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        TestH2 h2 = new TestH2();
        // 开始服务
        h2.startServer();
        h2.testH2();

        Class.forName("org.h2.Driver");
        JdbcDataSource JdbcDataSource=new JdbcDataSource();
        JdbcDataSource.setUrl("jdbc:h2:./test");
        JdbcDataSource.setUser("sa");
        JdbcDataSource.setPassword("");


        TransactionFactory transactionFactory = new JdbcTransactionFactory();
        Environment environment = new Environment("Production", transactionFactory, JdbcDataSource);

        Configuration configuration = new Configuration(environment);
        configuration.addMapper(PersonMapper.class);
        SqlSessionFactory sqlSessionFactory = new DefaultSqlSessionFactory(configuration);


        SqlSession sqlSession = sqlSessionFactory.openSession();

        PersonMapper personMapper = sqlSession.getMapper(PersonMapper.class);
        Person person=new Person();
        person.setId(1);
        Person person1= personMapper.queryByPrimaryKey(person);
        System.out.println(person1);

        h2.stopServer();


    }
 
开发者ID:ChenXun1989,项目名称:ace,代码行数:35,代码来源:TestMybatis.java


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