mybatis映射文件的配置及其实例

Mybatis 核心配置文件+映射文件操作基础 目录 每文一铺垫 核心配置文件标签及使用 顶层结构 1.properties标签 2.typeAliases 类型别名 3.mappers映射器 映射文件 映射文件如何关联 两个关键点: 收尾+剧透 每文一铺垫 小橙分享完Mybatis基础操作后,大家对于整体流程已经很清晰了,但是,在我们实际开发的过程中Mybatis中的两个重要部分:核心配置文件、映射文件,zzzz(大家可以猜一下这是什么词语,类似于yyds),而这正是Mybatis的关键部分之一,今天小橙就来分享... 阅读详情

一,使用xml文件直接映射

1.先传建一个实体类

package com.array.bean;

public class Mybatis {
	private String last_name;
	private Integer id ;
	private char gender;
	private String email;
	public String getLast_name() {
		return last_name;
	}
	public void setLast_name(String last_name) {
		this.last_name = last_name;
	}
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public char getGender() {
		return gender;
	}
	public void setGender(char gender) {
		this.gender = gender;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	
	
}

2,创建一个接口

package com.array.dao;

import com.array.bean.Mybatis;
/**
 * 接口式编程
 * 不用创建实现类通过文件配置进行实现
 * IMybatis
 * 创建人:jcy
 * 时间:2018年6月7日-上午11:46:56 
 * @version 1.0.0
 *
 */
public interface IMybatis {
	public Mybatis getMybatisById(Integer id);
        public Mybatis findUserByUserName(String last_name);

}

3.创建一个mapping.xml文件内容如下

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
  PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  <!-- 一个文件中只能存在一个mapper标签,一个mapper标签下可以放多个select标签 -->
    <!-- namespace:隔离SQL映射文件的,是一个SQL映射文件的唯一标识 -->

		<!-- <mapper namespace="user">
				SQL
			根据id查询用户信息   parameterType 传入参数类型
			<select id="getMybatisById" parameterType="int" resultType="com.array.bean.Mybatis">
				SELECT 
					*
				FROM mybatis 
				WHERE 
					id = #{id}
			</select>
			
			根据用户名查询用户信息(方式一:用占位符接收参数映射)
			<select id="findUserByUserName" parameterType="String" resultType="com.array.bean.Mybatis">
				SELECT 
					*
				FROM mybatis 
				WHERE 
					last_name LIKE #{last_name}
			</select>
		</mapper> -->
	
4.创建一个mybatis-config.xml文件,注册sql映射文件内容如下:
<?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>
   <!--  <settings>
        <setting name="jdbcTypeForNull" value="NULL"/>
    </settings>
   
	<properties resource="dbconfig.properties"></properties>
    <environments default="development">
        <environment id="development">
            <transactionManager type="JDBC"/>
            <dataSource type="POOLED" >
                <property name="driver" value="${jdbc.driver}"/>
                <property name="url" value="${jdbc.url}"/>
                <property name="username" value="${jdbc.username}"/>
                <property name="password" value="${jdbc.password}"/>
                <property name="poolMaximumActiveConnections" value="50"/>
            </dataSource>
        </environment>
    </environments>
<!-- 将写好的sql文件注册到全局 -->
    <mappers>
    	<mapper resource="com/array/mapper/mapping.xml"/>
    </mappers>


</configuration>

5.测试,使用junit进行模块测试

这里调用接口方法必须 namespace名字.方法名,

selectOne的第一个参数 namespace名字.方法名,后面跟要传参数

Mybatis userInfo = sqlSession.selectOne("user.findUserByUserName", "array");
public void test1() {
		String resource = "mybatis-config.xml";
		SqlSession sqlSession = null;
		// 读取配置文件
		InputStream inputStream = null;
		try {
			inputStream = Resources.getResourceAsStream(resource);
			// 根据配置文件创建会话工厂
			SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
			// 根据会话工厂创建会话对象
			sqlSession = sqlSessionFactory.openSession();
			System.out.println(sqlSession);
			// 根据id查询用户信息
			
			Mybatis userInfo = sqlSession.selectOne("user.findUserById", 1);
			System.out.println(userInfo);
		} catch (IOException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
			
		}finally{
			sqlSession.close();
		}
		
	}
	
	public void test0() throws Exception {
		String resource = "mybatis-config.xml";
		// 读取配置文件
		InputStream inputStream = Resources.getResourceAsStream(resource);
		// 根据配置文件创建会话工厂
		SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
		// 根据会话工厂创建会话对象
		SqlSession sqlSession = sqlSessionFactory.openSession();
		// 根据name查询用户信息
		Mybatis userInfo = sqlSession.selectOne("user.findUserByUserName", "array");
		System.out.println(userInfo);
		sqlSession.close();
	}

二,使用接口映射

上面方法的文件映射比较麻烦,每次创建一个sql映射文件,都需要将其配置到全局中,为了解决这个问题可以使用接口映射

使用这种方法需要注意的是,xml映射文件必须与接口同名,且包在同一个包目录下,这样就能配置一次,映射所有的sql语句xml文件

sql的xml文件举例如下:

<!--  namespace指定为接口的路径   id="getMybatis"是绑定接口中的方法-->
		<mapper namespace="com.array.dao.IMybatis">
			<select id="getMybatisById" parameterType="int" resultType="com.array.bean.Mybatis">
				SELECT 
				email
				FROM mybatis 
				WHERE 
					id = #{id}
			</select>

		</mapper>

测试:

@org.junit.Test
	public void test2() {
			//会为接口创建一个代理对象
			//获取sessionFactory对象
			SqlSessionFactory sqlSessionFactory = getsSqlSessionFactory();
			//获取sqlSession对象
			SqlSession sqlSession = sqlSessionFactory.openSession();
			//获取接口的实例类对象
			IMybatis mapper = sqlSession.getMapper(IMybatis.class);
			Mybatis mybatis = mapper.getMybatisById(1); 
			System.out.println(mybatis.getEmail());
			sqlSession.close();
		
		
	}


MyBatis-全局配置文件及SQL映射文件 文章目录1.全局配置文件1.1.properties引入外部配置文件1.2.settings运行时行为设置1.3.typeAliases别名1.4. environments运行环境1.5.mappers_sql映射注册2.映射文件参数处理2.1.单个参数2.2.多个参数2.2.1.命名参数2.2.2.POJO2.2.3.Map2.2.4.TO2.3.单个javaBean2.4.Map2.5.多个... 阅读详情

相关推荐

菲涅尔波带片

菲涅尔波带片的简介,以及matlab绘制

Bestchinese的博客 1万+

mybatis学习二-映射文件

先看一张图 不难发现, mybatis就是通过映射文件来管理sql语句的, 不再是传统的将sql语句写在代码中, 将sql和代码分开解耦了. 插入操作

weixin_45032905的博客 503

FFmpeg + OBS 低延迟直播串流实战:从H264裸流到RTP组播的完整配置

本文详细介绍了如何利用FFmpeg将H264裸流转码为RTP协议,并通过组播技术实现与OBS客户端的超低延迟直播串流。文章深入剖析了FFmpeg关键参数调优、SDP文件生成与配置,以及OBS客户端的无缝拉流方法,为需要毫秒级实时交互的场景提供了一套去中心化、高效稳定的完整解决方案。

fanta的博客 830

MyBatis(3)

1.MyBatis的配置文件 1.SQL映射文件 2.MyBatis的核心配置文件 在resources目录下的mybatis-config.xml文件 名称---我们可以自己定义,推荐大家使用【mybatis-config.xml】 位置---Intellij IDEA中通过Maven创建项目,一般保存在src/main/resources目录下 文件中的配置元素及其属性 MyBatis的核心配置文件是一个xml文件 1.文件头---<?xml version="1.0" endod

weixin_52821030的博客 425

别再手动画柜子了!用EPLAN导入STEP模型,5分钟搞定一个标准机柜

本文详细介绍了如何利用EPLAN Pro Panel的3D布局功能,快速将STEP模型转化为智能机柜宏,大幅提升电气工程设计效率。通过实战步骤解析,包括模型导入、智能解析、安装面定义及拼柜技巧,帮助工程师5分钟内完成标准机柜设计,避免传统手动建模的尺寸偏差问题。

weixin_26875109的博客 437

支持找回微信删除好友!一款人人可用的全能微信数据分析工具

找回删除好友、查看删除记录、恢复聊天信息....

1731

MyBatis之配置文件和映射文件

在使用 MyBatis 框架进行数据库操作时,需要配置 MyBatis 的配置文件和映射文件。这些文件用于定义数据库连接信息、映射规则以及 SQL 语句等。配置文件是 MyBatis 框架的核心配置文件,它包含了数据库连接信息、事务管理器配置、映射文件位置等信息。一般情况下,配置文件的名称为 mybatis-config.xml,并放置在项目的根目录下。映射文件是用于定义数据库表与实体类之间的映射关系的文件。它包含了 SQL 查询语句、结果集映射以及参数传递等信息。

liubopro666的博客 2444

GEE:计算非水体概率影像(水体淹没次数)

本文记录了在GEE平台上使用哨兵数据计算沿海地区非水体概率图像的计算方法和代码。基于像素,概率范围0-100。首先使用哨兵数据(s2)和大津算法(OTSU)计算的水体指数阈值来提取水体,然后计算研究区非水体像素在时间段内出现的概率。

养乐多的博客 2143

mybatis

一、搭建环境 1、创建MyBatis的核心配置文件,引入映射文件 <?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> <!--引入prope

Ayu___的博客 932

装配完整性检查系统:基于YOLOv10的螺丝/零件缺失自动检测(含UI界面与完整代码)

建议自行采集装配场景数据,标注缺失螺丝、错误零件等,模拟真实缺陷。手机/工业相机采集图像;使用LabelImg进行目标标注;转换为 YOLO 格式。本文构建了一个完整的装配完整性检测系统,基于 YOLOv10 实现高精度螺丝缺失检测,并使用 PyQt5 构建了图形界面,实现一键导入与可视化检测流程,适用于工业质检自动化部署。项目可灵活扩展至零件缺失、错装、错位、顺序错误等检测场景,是深度学习在制造业中落地的典型应用案例之一。

YOLO 706

软件测试面试题之易错题

(1)白盒测试:又称功能功能 测试、数据驱动测试和行为测试,是一种从用户观点出发的测试,被测程序为黑盒子, 通过测试来检测每个功能是否能够正常使用。(2)黑盒测试:又称结构测试和逻辑驱动 测试,是知道产品内部工作过程,通过测试来检测产品内部动作是否按照规格说明书 的规定去正常运行。(1)、测试需求分析;(2)动态白盒测试:需要对各个模块功能、模块间的接口、局部数据结构、主要执行路径、 错误处理等方面的测试。(2) 集成测试所测试的对象是模块间的接口,其目的是在找出在模块接口上面,包括整体体系结构上的问题;

m0_37449634的博客 682

在IDEA中配置Mybatis核心配置文件和映射文件的模板

Mybatis的配置文件和映射文件,有DTD和一些标签是必须,自己编写的话会记不住要引入的DTD,在IDEA中可以自定义文件的模板,到时候新建文件的时候就可以用这些模板,不需要手动去别的地方复制或者手动手写。配置文件步骤如下打开设置(Setting)-- 编辑器Editor – 文件和代码模板(File and Code Templates)-- 点击加号即可新建模板。

忆亦何为的博客 1337

ABAP 大规模数据并行处理实战,六套 Parallel Processing Framework 如何选,性能调优真正该盯住什么

如果今天真的面对那份执行 14 个小时的生产报表,我不会马上把原来的 Loop 改成 50 个aRFC。我会先用 SAT、ST12、SQL Monitor 和 HANA 侧工具确认时间到底花在哪里。如果 90% 时间其实消耗在一条低效 SQL 上,Parallel Processing 只是让 50 个 Worker 同时执行那条低效 SQL,数据库会比原来更痛苦。应该先把串行逻辑本身优化到合理水平。该做 Set-based Processing 的地方先交给 HANA。该避免SELECT。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 153

MyBatis——Mapper映射文件配置

本博文主要介绍Mapper映射文件配置,帮助大家更好的理解Mapper映射原理。帮助大家学习Mapper映射文件的使用与配置。在mapper文件中,以mapper作为根节点,其下面可以配置的元素节点有: select, insert, update, delete, cache, cache-ref, resultMap, sql; 本文将Mapper映射文件配置进行详解。

庄小焱 4275

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

MyBatis的配置文件与XML映射文件

1.背景介绍 MyBatis是一款非常流行的Java持久层框架,它可以简化数据库操作,提高开发效率。MyBatis的核心组件是映射文件,这些文件用于定义如何映射Java对象和数据库表。在本文中,我们将深入探讨MyBatis的配置文件和XML映射文件,揭示其核心概念、算法原理、最佳实践以及实际应用场景。 1.背景介绍 MyBatis起源于iBATIS项目,是一款高性能、易用的Java持久层框架...

AI天才研究院 1200

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

Mybatis源码05 - Mapper映射文件的配置

Mybatis源码05 - Mapper映射文件的配置

qq_43350524的博客 1148

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

MyBatis全局配置文件和映射文件

Mybatis文件的全局配置和映射文件: 配置文件MyBatis 的配置文件包含了影响 MyBatis 行为的设置(settings)和属性(properties)信息。 配置文件结构12345678910111213configuration 配置 properties 属性settings 设置typeAliases 类型命名type...

菜鸟清风http://www.hphblog.cn/ 1036

MyBatis的映射文件与XML配置

1.背景介绍 MyBatis是一款非常受欢迎的Java持久层框架,它可以简化数据库操作,提高开发效率。MyBatis的核心功能是将SQL映射到Java对象,这样我们可以更方便地操作数据库。在MyBatis中,映射文件是用于定义数据库表和Java对象之间关系的XML文件。在本文中,我们将深入了解MyBatis的映射文件和XML配置,并探讨其核心概念、算法原理、最佳实践、实际应用场景和工具推荐。 ...

AI天才研究院 1202

Mybatis的映射文件的配置

Mybatis映射文件的配置 一、映射文件mapper.xml的主要配置元素 select:查询语句,最常用,最复杂的语句之一 insert:插入语句 update:更新语句 delete:删除语句 sql:定义sql语句的一部分,尽量是可以复用的那部分 resultMap:用来描述从数据库集中加载对象,提供映射规则 二、主要元素的描述 1 、select 它是用于映射sql语句中的selec...

qq_45646289的博客 867

mybatis映射文件配置

二. 映射文件xml配置 1. dtd文件约束xml语法规则 <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dt...

辣椒的博客 378

Spring集成Mybatis配置映射文件方法详解

Spring ORM模块集成Mybatis使用到了mybatis-spring,在配置mybatis映射文件的时候,一般不直接在Mybatis的配置文件里进行配置,而会在Spring的配置文件里使用MapperScannerConfigurer来配置。MapperScannerConfigurer会自动扫描basePackage指定的包,找到映射接口类和映射XML文件,并进行注入。

渴望,就奋力追寻... 4581

Mybatis第二章 映射文件配置

标题1.XML 映射文件 MyBatis 的真正强大在于它的映射语句,这是它的魔力所在。由于它的异常强大,映射器的 XML 文件就显得相对简单。如果拿它跟具有相同功能的 JDBC 代码进行对比,你会立即发现省掉了将近 95% 的代码。MyBatis 为聚焦于 SQL 而构建,以尽可能地为你减少麻烦。 标题.2.顶级元素 cache – 对给定命名空间的缓存配置 cache-ref – 对其他命名空...

weixin_45419424的博客 277

mybatis-generator-core生成配置mybatis映射文件

mybatis-generator-core-1.3.2生成mybatis映射文件

saber 1061

mybatis的xml映射文件配置

用于较大、较复杂的项目,简单的项目建议使用注解配置。

2301_80749359的博客 576

MyBatis配置&映射文件头

配置文件 <?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> <environments default="development"> <envir

Ezerbel的博客 1914
上一篇: Myeclipse2014的安装与破解步骤
下一篇: mybatis级联分布查询的例子
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值