MyBatis注解开发

Mybatis注解开发(超详细) 注解说明@Insert实现新增@Delete实现删除@Update实现更新@Select实现查询@Result实现结果集封装@Results可以与@Result 一起使用,封装多个结果集@ResultMap实现引用@Results 定义的封装@One实现一对一结果集封装@Many实现一对多结果集封装@SelectProvider实现动态 SQL 映射@CacheNamespace实现注解二级缓存的使用User: 使用注解方式开发持久层接口 IUserDao: 编写 SqlMapConfig.xml 配置文 阅读详情

目录

1.常用注解

2.使用xml配置开发

3.使用注解开发

4.MyBatis的注解实现复杂映射开发

4.1一对一查询

4.2一对多查询

4.3多对多查询

1.常用注解

  • @Insert:实现新增
  • @Update:实现更新
  • @Delete:实现删除
  • @Select:实现查询
  • @Result:实现结果集封装
  • @Results:可以与@Result一起使用,封装多个结果集
  • @One:实现一对一结果集封装
  • @Many:实现一对多结果集封装

2.使用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 namespace="com.caoyan.mapper.UserMapper">
    <!-- 增 -->
    <insert id="save" parameterType="user">
        insert into user values(#{id},#{username},#{password},#{birthday})
    </insert>
    <!-- 删 -->
    <delete id="delete" parameterType="int">
        delete from user where id=#{id}
    </delete>
    <!-- 改 -->
    <update id="update" parameterType="user">
        update user set username=#{username},password=#{password},birthday=#{birthday} where id=#{id}
    </update>
    <!-- 根据id查 -->
    <select id="findById" parameterType="int" resultType="user">
        select * from user where id=#{id}
    </select>
    <!-- 查询所有 -->
    <select id="findAll" resultType="user">
        select * from user
    </select>
</mapper>
    <!-- 加载映射文件 -->
    <mappers>
        <mapper resource="com/caoyan/mapper/UserMapper.xml"/>
    </mappers>

3.使用注解开发

package com.caoyan.mapper;

import java.util.List;

import com.caoyan.domain.User;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface UserMapper {
    @Insert("insert into user values(#{id},#{username},#{password},#{birthday})")
    public void save(User user);

    @Update("update user set username=#{username},password=#{password},birthday=#{birthday} where id=#{id}")
    public void update(User user);

    @Delete("delete from user where id=#{id}")
    public void delete(int id);

    @Select("select * from user where id=#{id}")
    public User findById(int id);

    @Select("select * from user")
    public List<User> findAll();
}
    <!-- 加载映射关系 -->
    <mappers>
        <!-- 指定接口所在的包 -->
        <package name="com.caoyan.mapper" />
    </mappers>

4.MyBatis的注解实现复杂映射开发

注解说明
@Results代替的是标签<resultMap>该注解中可以使用单个@Result注解,也可以使用@Result集合。使用格式:@Results({@Result(),@Result()})或@Results(@Result())
@Result

代替了<id>标签和<result>标签

@Result中属性介绍

column:数据库的列名

property:需要装配的属性名

one:需要使用的@one注解(@Result(one=@one)())

many:需要使用的@Many注解(@Result(many=@many)())

4.1一对一查询

package com.caoyan.mapper;

import java.util.List;

import com.caoyan.domain.Order;
import com.caoyan.domain.User;

import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

public interface OrderMapper {
    // @Select("select *,o.id oid from orders o, user u where o.uid=u.id")
    // @Results({
    // @Result(column = "oid", property = "id"),
    // @Result(column = "ordertime", property = "ordertime"),
    // @Result(column = "total", property = "total"),
    // @Result(column = "uid", property = "user.id"),
    // @Result(column = "username", property = "user.username"),
    // @Result(column = "password", property = "user.password")
    // })
    @Select("select * from orders")
    @Results({
            @Result(column = "oid", property = "id"),
            @Result(column = "ordertime", property = "ordertime"),
            @Result(column = "total", property = "total"),
            @Result(property = "user", // 要封装的属性名称
                    column = "uid", // 根据哪个字段去查询user表的数据
                    javaType = User.class, // 要封装的实体类型
                    // select属性代表查询哪个接口的方法获得数据
                    one = @One(select = "com.caoyan.mapper.UserMapper.findById"))
    })
    public List<Order> findAll();
}

4.2一对多查询

    @Select("select * from orders where uid=#{uid}")
    public List<Order> findByUid(int uid);
    @Select("select *from user")
    @Results({
            @Result(id = true, column = "id", property = "id"),
            @Result(column = "username", property = "username"),
            @Result(column = "password", property = "password"),
            @Result(property = "orderList", column = "id", javaType = List.class, many = @Many(select = "com.caoyan.mapper.OrderMapper.findByUid"))
    })
    public List<User> findUserAndOrderAll();
package com.caoyan.test;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import com.caoyan.domain.User;
import com.caoyan.mapper.UserMapper;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Before;
import org.junit.Test;

public class MyBatisTest3 {
    private UserMapper userMapper;

    @Before
    public void before() throws IOException {
        InputStream resourceAsStream = Resources.getResourceAsStream("sqlMapConfig.xml");
        SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(resourceAsStream);
        SqlSession sqlSession = sessionFactory.openSession(true);
        userMapper = sqlSession.getMapper(UserMapper.class);
    }

    @Test
    public void testFindAll() {
        List<User> userList = userMapper.findUserAndOrderAll();
        for (User user : userList) {
            System.out.println(user);
        }
    }

}

4.3多对多查询

package com.caoyan.mapper;

import java.util.List;

import com.caoyan.domain.Role;

import org.apache.ibatis.annotations.Select;

public interface RoleMapper {
    @Select("select * from sys_user_role ur,sys_role r where ur.roleId=r.id and ur.userId=#{uid}")
    public List<Role> findByUid(int uid);
}
    @Select("select * from user")
    @Results({
            @Result(id = true, column = "id", property = "id"),
            @Result(column = "username", property = "username"),
            @Result(column = "password", property = "password"),
            @Result(property = "roleList", column = "id", javaType = List.class, many = @Many(select = "com.caoyan.mapper.RoleMapper.findByUid"))
    })
    public List<User> findUserAndRoleAll();
package com.caoyan.test;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import com.caoyan.domain.User;
import com.caoyan.mapper.UserMapper;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Before;
import org.junit.Test;

public class MyBatisTest4 {
    private UserMapper userMapper;

    @Before
    public void before() throws IOException {
        InputStream resourceAsStream = Resources.getResourceAsStream("sqlMapConfig.xml");
        SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(resourceAsStream);
        SqlSession sqlSession = sessionFactory.openSession(true);
        userMapper = sqlSession.getMapper(UserMapper.class);
    }

    @Test
    public void testFindAll() {
        List<User> userList = userMapper.findUserAndRoleAll();
        for (User user : userList) {
            System.out.println(user);
        }
    }

}

MyBatis(三、注解开发) 实现复杂关系映射之前我们可以在映射文件中通过配置来实现,使用注解开发后,我们可以使用@Results注解 ,@Result注解,@One注解,@Many注解组合完成复杂关系的配置。​ 修改MyBatis的核心配置文件,我们使用了注解替代的映射文件,所以我们只需要加载使用了注解的Mapper接口即可。这几年来注解开发越来越流行,Mybatis也可以使用注解开发方式,这样我们就可以减少编写Mapper 映射文件了。......... 阅读详情

相关推荐

【雷达图】R语言绘制雷达图(ggradar),NBA季后赛数据为例

一起用R语言给nba球星画球技雷达图吧!

池塘春草梦的博客 6252

Mybatis注解开发

因为xml开发的配置,过于繁琐,为了提升开发效率,有了注解开发,只要的都可以使用注解开发,但如果结果集的数据来自于,那还是更建议使用一对一、一对多、多对多的方式,xml和注解是可以的。

冬眠猫的博客 9176

SpringBoot整合海康SDK实战:从设备初始化到PS流录像转MP4全流程(附避坑指南)

本文详细介绍了SpringBoot整合海康SDK的完整实战流程,涵盖设备初始化、通道管理、录像检索与下载。针对海康设备生成的PS流录像文件无法直接播放的痛点,重点解析了如何利用FFmpeg高效、无损地将其转换为通用的MP4格式,并提供了关键的避坑指南和性能优化建议。

chair的专栏 765

mybatis注解开发

mybatis注解开发 1.概述 Mybatis最大的特点是使用XML存储SQL语句,但是Mybatis也可以使用注解开发方式,好处是不用编写Mapper映射文件,坏处是SQL语句又耦合在Java代码中了。本次我们先围绕一些基本的 CRUD 来学习,再学习复杂映射关系及延迟加载。 2.Mybatis的注解说明 @Insert:实现新增 @Update:实现更新 @Delete:实现删除 @Select:实现查询 @Result:实现结果集封装 @Results:可以与@Result一起使用,封装多个结果集

xiaotai1234的博客 411

通义万相Wan2.1模型Lora训练以及推理

使用DiffSynth-Studio进行通义万象Wan2.1的Lora训练和推理

qq_64858624的博客 4605

comsol移动网格_comsol模拟移动的纳秒脉冲激光烧蚀材料,温度场分布,结果总不理想,求助大佬!!...

本人comsol新手一枚,希望大家多多指点研究课题:纳秒脉冲激光刻蚀材料表面想用comsol模拟刻蚀过程中的温度场分布,脉宽为300ns,重复频率100kHz,光斑移动速度为5000mm/s,光斑直径50um,激光功率10W,材料种类为:有机涂层,属性如下目前,采用的是一个移动的高斯面光源x脉冲函数,脉冲函数我用的是一个周期性方波:周期性拓展后,画出来的脉冲图,不知道为什么在0~1s的区间内只有1...

weixin_33288893的博客 4745

@column注解_Mybatis 注解开发

这几年来注解开发越来越流行,Mybatis 也可以使用注解开发方式,这样我们就可以减少编写 Mapper 映射 文件了。本次我们先围绕一些基本的 CRUD 来学习,再学习复杂映射关系及延迟加载。 3.1 mybatis 的常用注解说明 @Insert3.2 使用 Mybatis 注解实现基本 CRUD 单表的 CRUD 操作是最基本的操作,前面我们的学习都是基于 Mybaits 的映射文件来实现的...

weixin_39855944的博客 925

概率论与数理统计基础概念与重要定义汇总

文章目录一、随机事件和概率1:互斥,对立,独立事件的定义和性质。2:概率,条件概率和五大概率公式3:古典型,几何型概率和伯努利试验 一、随机事件和概率 1:互斥,对立,独立事件的定义和性质。 互斥事件\color{red}\textbf{互斥事件}互斥事件 事件A和B的交集为空,A与B就是互斥事件,也叫互不相容事件。也可叙述为:不可能同时发生的事件。如A∩B为不可能事件(A∩B=Φ),那么称事件A与事件B互斥,其含义是:事件A与事件B在任何一次试验中不会同时发生。 则P(A+B)=P(A)+P(B)(这个公

csyifanZhang的博客 1万+

MyBatis系统学习(五)——MyBatis的注解开发

MyBatis 是一个支持自定义 SQL、存储过程和高级映射的持久层框架。除了传统的 XML 方式外,MyBatis 还提供了注解的方式进行 SQL 操作定义。这种注解方式将 SQL 直接写在 Java 接口方法上,简化了开发过程,便于维护和使用。@Select:执行查询 SQL。@Insert:执行插入 SQL。@Update:执行更新 SQL。@Delete:执行删除 SQL。@Results@Result:定义结果集的映射。@One@Many:用于处理关联查询(一对一和一对多)。

2301_79858914的博客 2643

Python爬虫实战:深度解析携程/飞猪酒店评论API与大数据采集

本文详细介绍了如何通过Python爬虫技术获取携程和飞猪平台的酒店评论数据。我们涵盖了从API分析、反爬虫对策到数据存储和处理的完整流程。API逆向分析:通过浏览器开发者工具发现和分析API接口反爬虫对策:使用请求头随机化、IP代理、浏览器自动化等技术异步处理:使用asyncio提高爬取效率数据质量:实现数据清洗和质量检查机制系统架构:构建可扩展的分布式爬虫系统未来改进方向:机器学习识别验证码分布式爬虫架构实时数据流处理更智能的反反爬虫策略。

2201_76125261的博客 602

在 Fiori Elements Object Page 的表格中用 UI.Hidden 隐藏列:语义、边界与落地实践全解析

摘要: Fiori Elements的Object Page表格中,UI.Hidden注解支持静态和动态隐藏列。动态隐藏分为两种:基于父实体属性隐藏整列,或基于子实体属性按行隐藏单元格。关键约束包括:支持服务端操作的列禁止使用动态隐藏,否则会导致UX不一致。ABAP CDS不支持路径式UI.Hidden,需改用XML注解。该功能需与UI.Importance、个性化等机制明确区分,避免混淆。对于可能参与排序/过滤的列,建议仅使用静态隐藏。实际应用中需注意注解位置(整列或单元格级)和业务场景的匹配。

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

MyBatis 注解开发详解

MyBatis 提供了基于 XML 配置和基于注解的两种开发方式。注解方式相对简单,但实际开发中更推荐使用 XML 配置方式,以减少对源代码的修改,提高可维护性。注解方式可以快速开发,但 XML 配置更具灵活性和可维护性。@One和@Many结合可以实现延迟加载,优化查询性能。CRUD 操作通过@Insert@Select@Update@Delete进行实现。一对多、多对一映射可以用@One和@Many进行关联查询。

Future_yzx的博客 1065

Oracle EBS(R12+)通过Multi-Org 多组织架构、Multi-Ledger 多账簿、SLA 子分类账会计、多币种引擎、多会计政策并行五大核心能力,为跨国企业提供一体化、自动化、合规的

Oracle EBS(R12+)提供全球会计核算解决方案,通过Multi-Org多组织架构实现跨国集团数据隔离与共享,支持四层组织结构(业务组→法律实体→经营单位→库存组织)。Multi-Ledger多账簿功能允许一笔业务多准则自动核算,包含主账簿、辅助账簿和报告币种。系统内置多币种处理引擎,覆盖全流程货币业务,支持自动重估、再计量和折算。通过SLA子分类账会计实现多会计政策并行处理,满足不同国家会计准则和税制要求。该方案可同时支持本地法定、集团合并及管理分析需求,实现全球财务数据集中管理,提升合规性和运营

金牌架构师 554

【MyBatis】Mybatis 注解开发

【MyBatis】Mybatis 注解开发1. 常用的注解说明2. 通过注解实现基本CRUD操作3. 使用注解实现一对多复杂关系映射3.1 复杂关系映射的注解说明3.2 使用注解实现一对一复杂关系映射及延迟加载3.3 使用注解实现一对多复杂关系映射及延迟加载4. 基于注解的二级缓存 1. 常用的注解说明 @Insert:实现新增 @Update:实现更新 @Delete:实现删除 @Select:...

来日浅谈的博客 544

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

MyBatis:注解开发

在 MyBatis 的开发体系中,注解开发作为 XML 配置的补充方案,以其简洁直观的语法大幅简化了基础 CRUD 操作的代码编写。然而需要明确的是,该方式更适用于简单业务场景,—— 复杂 SQL 的维护性、动态 SQL 的灵活性等方面仍不及 XML 配置。本文将从核心注解、配置方式、关联查询实现到测试流程,全面拆解 MyBatis 注解开发的关键知识点。

2403_89732016的博客 584

深度学习工具包 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注解开发 @Insert注解注解属性value:写入SQL语句 @Options注解实现添加新数据的主键封装注解属性useGeneratedKeys:使用生成的主键,配置为truekeyProperty:主键封装的pojo对象属性 @SelectKey注解实现添加新数据的主键封装注解属性statement:要执行的SQL语句before:在添加SQL语句之前还是之后进行,配置为...

weixin_30289831的博客 112

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

Mybatis 注解开发

实现复杂关系映射之前我们可以在映射文件中通过配置来实现,使用注解开发后,我们可以使用 @Results 注解,@Result 注解,@One 注解,@Many 注解组合完成复杂关系的配置。用户表和订单表的关系为,一个用户有多个订单,一个订单只从属于一个用户。用户表和订单表的关系为,一个用户有多个订单,一个订单只从属于一个用户。一对一查询的需求:查询一个订单,与此同时查询出该订单所属的用户。一对多查询的需求:查询一个用户,与此同时查询出该用户具有的订单。多对多查询的需求:查询用户同时查询出该用户的所有角色。

丿灬老街的博客 687

Mybatis 使用注解开发

Param多参数方法,避免参数混淆通过名字直接引用参数,尤其在动态 SQL 中#{}与${}${}和#{}的区别_#{}和${}-优快云博客lambokLombok 使用教程(超级详细) - 犬小哈教程是什么?一个java库,通过注解的方式简化了java代码的编写。

redemption_2的博客 936

Mybatis基于注解开发的CRUD

1、Mybatis中有两种sql语句的书写形式 1、第一个就是我们之前文章一直在用的配置文件xml形式。 2、第二个就是基于注解开发,其实注解开发要比配置文件开发好用的多。 2、项目目录 在这里中没有关于映射的配置文件 3、数据库表的信息 4、CRUD 方法都是放在IUserDao接口中 查询所有的信息 @Select("select * from users") List<...

Zystem 2683
上一篇: SSM整合
下一篇: LeNet网络模型的搭建与训练
Caoyy686868
博客等级 码龄8年 5742粉丝 57原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Caoyy686868

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值