mapper

mybatis配置文件

隐身守侯 提交于 2019-12-11 15:59:55
SqlMapConfig.xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration> <!--导入数据库properties配置文件--> <properties resource="db.properties" /> <settings> <!--开启二级缓存--> <setting name="cacheEnabled" value="true"/> <!--开启懒加载--> <setting name="lazyLoadingEnabled" value="true"/> </settings> <!--别名--> <typeAliases> <!--配置单个别名--> <!-- <typeAlias type="com.royal.model.User" alias="user"></typeAlias>--> <package name="com.royal.model"/> <package name="com.royal.vo"/> </typeAliases> <!--

[SpringCloud]~常用架构分层

◇◆丶佛笑我妖孽 提交于 2019-12-11 15:46:31
目录 常用架构分层 commom(公共业务代码层) config(配置层) controller(控制层) DTO(Data Transfer Object 数据传输对象) mapper(数据持久层) VO(Value Object 值对象) domain/model(数据模型层) service(业务层) Impl(业务实现层) task (定时任务) util(工具类) 常用架构分层 commom(公共业务代码层) 公用的业务处理方法,业务代码 没有feign、Http包时,喜欢将外部调用通用方法也放在此包 config(配置层) 存放相关配置类 swagger2Config RestTemplateConfiguration OkHttpConfig FilePathConfig SpringCacheConfig JacksonConfig ValidatorConfig PageHelperConfiguration controller(控制层) 负责请求转发 接受前端参数传给service层 接受service层的返回结果,传给前端 DTO(Data Transfer Object 数据传输对象) 用于接收前端传递的参数 mapper(数据持久层) 数据持久化 对service层提供数据操作接口 接口对应mybitas中Mapper.xml VO(Value

Hadoop: number of available map slots based on cluster size

回眸只為那壹抹淺笑 提交于 2019-12-11 14:02:13
问题 Reading the syslog generated by Hadoop, I can see lines similar to this one.. 2013-05-06 16:32:45,118 INFO org.apache.hadoop.mapred.JobClient (main): Setting default number of map tasks based on cluster size to : 84 Does anyone know how this value is computed? And how can I get this value in my program? 回答1: I grepped the source code of Hadoop and did not find the string Setting default number of map tasks based on cluster size to at all (whereas I find other strings, which are being printed

MyBatis开发Dao的原始Dao开发和Mapper动态代理开发

痞子三分冷 提交于 2019-12-11 08:10:53
目录 咳咳...初学者看文字(Mapper接口开发四个规范)属实有点费劲,博主我就废了点劲做了如下图,方便理解: 原始Dao开发方式 1. 编写映射文件 3.编写Dao实现类 4.编写Dao测试 Mapper动态代理方式 1.定义Mapper.xml(映射文件) 2、编写UserMapper.xml配置文件内容: 3.编写UserMapper(接口文件) 4.加载UserMapper.xml文件 5.编写测试 @ 使用MyBatis开发Dao,通常有两个方法,即原始Dao开发方法和Mapper动态代理开发方法。原始Dao开发中存在以下问题: Dao方法体存在重复代码:通过SqlSessionFactory创建SqlSession,调用SqlSession的数据库操作方法 调用sqlSession的数据库操作方法需要指定statement的id,这里存在硬编码,不得于开发维护。 而动态代理开发中Mapper接口开发方法只需要程序员编写Mapper接口(相当于Dao接口),由 Mybatis框架根据接口定义创建接口的动态代理对象,代理对象的方法体同上边Dao接口实现类方法。 使用mapper代理的方法来开发dao时,程序员 只需要干两件事 即可: 1、 编写mapper.xml映射文件 2、 编写mapper接口(相当于dao接口) Mapper接口开发需要遵循以下 四个规范

Run multiple reducers on single output from mapper

萝らか妹 提交于 2019-12-11 04:48:21
问题 I am implementing a left join functionality using map reduce. Left side is having around 600 million records and right side is having around 23 million records. In mapper I am making the keys using the columns used in left join condition and passing the key-value output from mapper to reducer. I am getting performance issue because of few mapper keys for which number of values in both the tables are high (eg. 456789 and 78960 respectively). Even though other reducers finish their job, these

mybatis开发dao方法(二)——Mapper代理开发方法(mapper接口)

此生再无相见时 提交于 2019-12-11 00:53:30
思路: 在遵循规范(如下对应关系)的前提下编写mapper接口文件,mybatis自动生成mapper接口实现类代理对象 对应关系: mapper接口 mapper.xml 接口地址 namespace 方法名 statement的id 方法输入参数类型 parameterType类型 方法返回值类型 resultType类型 实现步骤: 1. po类创建: public class User { private int id; private String username; private String sex; private Date birthday; private String address; } 2. mapper.xml <mapper namespace="cn.itcast.mybatis.mapper.UserMapper"> <!-- 根据id获取用户信息 --> <select id="findByUserId" parameterType="int" resultType="cn.itcast.mybatis.po.User"> select * from user where id = #{id} </select> </mapper> 3. SqlMapConfig.xml配置 <mappers> <mapper resource="Sqlmap

MappedStatement注册过程

泄露秘密 提交于 2019-12-11 00:17:01
文章目录 MapperStatement注册过程 MapperStatement注册时序 XMLConfigBuilder的mapperElement方法 XMLMapperBuilder的parse方法 解析cacheRef标签 解析cache标签 解析parameterMap标签 解析resultMap标签 解析sql片段 解析select等sql语句 MapperStatement注册过程 MapperStatement注册时序 MapperStatement的注册过程发生在Mybatis启动时构造Configuration对象的时候,XMLConfigBuilder对象的mapperElement方法负责解析Mapper文件并进行注册。 private void parseConfiguration ( XNode root ) { try { //issue #117 read properties first propertiesElement ( root . evalNode ( "properties" ) ) ; Properties settings = settingsAsProperties ( root . evalNode ( "settings" ) ) ; loadCustomVfs ( settings ) ; loadCustomLogImpl

Mapper方法调用过程

此生再无相见时 提交于 2019-12-10 23:15:56
文章目录 Mapper方法调用过程 Mapper方法调用时序 MapperProxy拦截目标方法执行 MapperMethod的execute方法 SqlCommand MethodSignature Mapepr方法签名 ParamNameResolver解析Mapper方法参数 Mapper方法调用过程 Mapper方法调用时序 @Test public void testMybatis ( ) throws IOException , SQLException { BaseDataTest . createBlogDataSource ( ) ; InputStream inputStream = Resources . getResourceAsStream ( "MapperConfig.xml" ) ; SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder ( ) . build ( inputStream ) ; SqlSession sqlSession = sqlSessionFactory . openSession ( ) ; CachedAuthorMapper cachedAuthorMapper = sqlSession . getMapper (

TangYuan之数据映射

£可爱£侵袭症+ 提交于 2019-12-10 23:13:02
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 7. 数据映射 7.1 数据类型映射 数据类型映射指的是数据库中的数据类型和Java数据类型之间的映射关系:比如:默认情况下,Mysql中的 int 类型对应Java中的 int(Integer) 类型, bigint 对应Java中的 BigInteger , decimal 对应Java中的 bigDecimal 等等,这些都是Tangyuan框架提供的默认映射关系,但如果我们希望数据库中的bigint能映射成Java中的long类型,或者decimal映射成Java中的double类型,该如何处理呢?我们可以通过下面的配置来实现我们的目的: 示例: <!-- 数据类型映射 --> <dataTypeMapping> <relation jdbcType="tinyint" javaType="int" /> <relation jdbcType="bigint" javaType="long" /> <relation jdbcType="double" javaType="float" /> <relation jdbcType="real" javaType="float" /> <relation jdbcType="decimal" javaType="float" /> <relation

Orika: How to map using a nested mapper

匆匆过客 提交于 2019-12-10 23:07:41
问题 Consider the following situation: public class A { private ClassInA classInA; public ClassInA getClassInA() { return classInA; } public void setClassInA(ClassInA classInA) { this.classInA = classInA; } } public class B { private ClassInB classInB; public ClassInB getClassInB() { return classInB; } public void setClassInB(ClassInB classInB) { this.classInB = classInB; } } public class ClassInA { private String myString; public String getMyString() { return myString; } public void setMyString