随笔分类 -  Java.Mybatis

摘要:还得使用XML注释 ,SQL注释--.Java注释 // /* */都会导致错误。 阅读全文
posted @ 2022-06-01 06:31 逆火狂飙 阅读(478) 评论(0) 推荐(0)
摘要:Html转义字符: HTML转义字符 字符 意义 &nbsp; 不断行的空格 &ensp; 半方大的空格 &emsp; 全方大的空格 &lt; 小于 < &gt; 大于 > &amp; &符号 &quot; 双引号" &copy; 版权符号© &reg; 已注册商标® &trade; 商标(美国)T 阅读全文
posted @ 2022-06-01 06:09 逆火狂飙 阅读(115) 评论(0) 推荐(0)
摘要:include标签在jsp和themeleaf中利用率很高,同样的复用功能在mybatis里也有体现,用法也差不多。 具体来说:就是把可能多次使用的SQL片段封装到一个sql标签中,冠以id,需要使用时便以include标签把其内容拉取过来。 比如下文的XML中: <mapper namespace 阅读全文
posted @ 2022-05-29 08:50 逆火狂飙 阅读(721) 评论(0) 推荐(0)
摘要:有一个EmpMapper.java,里面获取全部数据的fetchAll函数是这样写的: @Mapper public interface EmpMapper { List<Emp> fetchAll(); } 而对应的Empmapper.xml会是这样: <mapper namespace="com 阅读全文
posted @ 2022-04-30 19:53 逆火狂飙 阅读(66) 评论(0) 推荐(0)
摘要:Oracle数据库中,ID的生成机制多见使用sequence,如Mapper层的以下函数: @Insert(" insert into dmo_task(id,project_id,table_name,fromDsIdx,toDsIdx,userid) values(dmo_task_id_sqs 阅读全文
posted @ 2022-03-26 17:09 逆火狂飙 阅读(790) 评论(0) 推荐(0)
摘要:【前篇】 Oracle的三种分页方式 【Mapper类中的对应函数】 package com.hy.mapper; import com.hy.entity.Project; import org.apache.ibatis.annotations.Mapper; import java.util. 阅读全文
posted @ 2022-03-26 10:52 逆火狂飙 阅读(563) 评论(0) 推荐(0)
摘要:用||连接百分号和keyword是关键。 <select id="countPrj" resultType="java.lang.Integer"> select count(*) from dmo_project a where a.userid=#{uid} <if test="keyword 阅读全文
posted @ 2022-03-26 10:38 逆火狂飙 阅读(342) 评论(0) 推荐(0)
摘要:【实验用到的数据库】 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production 【实验用到的Mybatis版本】 <dependency> <groupId>org.mybatis</groupId> < 阅读全文
posted @ 2022-03-03 10:37 逆火狂飙 阅读(998) 评论(2) 推荐(0)
摘要:【前篇】 https://www.cnblogs.com/heyang78/p/15937919.html https://www.cnblogs.com/heyang78/p/15937891.html 【纲领】 用jdbc处理clob字段,存入时需要创建Clob对象,然后以setString(1 阅读全文
posted @ 2022-02-26 21:39 逆火狂飙 阅读(3626) 评论(0) 推荐(0)
摘要:【错误的发生场合】 当把null值赋给一个字段时。 【应对措施】 MyBatis官方文档指出:“如果对一个属性字段,需要传递null入内,jdbcType是必要的。” 所以,对于给属性字段可能赋空值的场合,需要显式指定可能为空的参数类型,如: update_uid=#{uid,jdbcType=NU 阅读全文
posted @ 2021-12-28 06:21 逆火狂飙 阅读(723) 评论(0) 推荐(0)
摘要:【程序】 package test; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Test4 { public static void main(String[] args) { Strin 阅读全文
posted @ 2021-12-27 21:38 逆火狂飙 阅读(335) 评论(0) 推荐(0)
摘要:函数: List<Variable> searchVarsInNames(@Param("names") List<String> names,@Param("uid") long uid); Mapper.xml: <select id="searchVarsInNames" resultType 阅读全文
posted @ 2021-12-08 21:38 逆火狂飙 阅读(1052) 评论(0) 推荐(0)
摘要:如果把SQL写在类中或是注解中,当要取select count(*) .... 类型sql的返回值,直接指定函数的返回类型为int/long即可; 但对于把sql语句写在XML文件的情况,如果要取select count(*) .... 的返回值,必须要指明结果类型resultType="java. 阅读全文
posted @ 2021-11-29 20:18 逆火狂飙 阅读(3576) 评论(0) 推荐(0)
摘要:第一种方式:直接将SQL语句写在接口类里,如: @Mapper public interface UserMapper { ... @Select(" select * from mc_user where name=#{name} and pswd=#{pswd} ") User findByNa 阅读全文
posted @ 2021-10-28 21:27 逆火狂飙 阅读(290) 评论(0) 推荐(0)
摘要:严格来说,本文讲述的只是oracle的内容,但因为1Mpper类里写的SQL,故而就和MyBatis挨上了。 表定义: create table mc_user( id number(8), deleted number(1) default 0, create_time timestamp def 阅读全文
posted @ 2021-10-12 21:14 逆火狂飙 阅读(128) 评论(0) 推荐(0)
摘要:本文适用于SpringBoot2.5.4,Mybatis2.2.0,mybatis-plus3.0.5版本,不保证在其它版本的适用性。 与本文相关的姊妹篇:https://www.cnblogs.com/heyang78/p/15369564.html 本文例程:https://files.cnbl 阅读全文
posted @ 2021-10-06 17:05 逆火狂飙 阅读(8547) 评论(0) 推荐(0)
摘要:本文适用于SpringBoot2.5.4,Mybatis2.2.0,mybatis-plus3.0.5版本,不保证在其它版本的适用性。 例程下载:https://files.cnblogs.com/files/heyang78/redisCache_LambdaQueryWrapper_211005 阅读全文
posted @ 2021-10-05 20:59 逆火狂飙 阅读(8488) 评论(0) 推荐(0)
摘要:SpringBoot版本:2.5.4 后台数据库:Oracle11g 访问数据库:MyBatis 例程下载:https://files.cnblogs.com/files/heyang78/redisCache_crud_oracle_mybatis_0925.rar Pom.xml中配置: <!- 阅读全文
posted @ 2021-09-25 17:13 逆火狂飙 阅读(50) 评论(0) 推荐(0)
摘要:本文涉及Springboot版本:2.5.4 例程:https://files.cnblogs.com/files/heyang78/myBank_transactional_210909_0526.rar 前言:使用JDBC操作单机数据库时,利用Connection对事务处理保证多个操作的不可分割 阅读全文
posted @ 2021-09-09 05:24 逆火狂飙 阅读(298) 评论(0) 推荐(0)
摘要:本文例程下载:https://files.cnblogs.com/files/heyang78/myBank_themeleaf_post_addstu_210906.rar 第一步:准备含有form的页面。 ...... <table border="0px" width="160px"> <tb 阅读全文
posted @ 2021-09-06 14:40 逆火狂飙 阅读(848) 评论(0) 推荐(0)

生当作人杰 死亦为鬼雄 至今思项羽 不肯过江东