目录

1、MybatisPlus简介

2、MybatisPlus注解介绍

3、常用方法

4、SpringBoot整合MybatisPlus实现增删改查的一个简单Demo

5、参考资料


1、MybatisPlus简介

Mybatis和MybatisPlus都是非常流行的持久层框架。mybatis可以直接在xml或注解中通过SQL语句操作数据库,很是灵活。但是其操作都要通过SQL语句进行,就必须写大量的xml文件或者注解sql语句,很是麻烦。而mybatis-plus就很好的解决了这个问题。

Mybatis-Plus(简称MP)是 Mybatis 的增强工具,在 Mybatis 的基础上只做增强不做改变,为简化开发、提高效率而生。关于mybatis-plus的更多介绍及特性,可以参考mybatis-plus官网

mybatis-plus已经封装好了一些crud方法,我们不需要再写SQL语句了,直接调用这些方法就行

2、MybatisPlus注解介绍

  • @TableId 关联主键,可以通过type属性指定是否自增
  • @TableName 通过value属性关联表名,当类名与表名一致时,value属性可省写
  • @TableField 关联表字段,如果属性名称与字段名称一致则此注解可以省写(包含驼峰规则)

3、常用方法

MybatisPlus常用方法可以去看BaseMapper这个接口。BaseMapper这个接口里面封装了一些常用的sql。

public interface BaseMapper<T> extends Mapper<T> {
int insert(T entity); int deleteById(Serializable id); int deleteByMap(@Param("cm") Map<String, Object> columnMap); int delete(@Param("ew") Wrapper<T> wrapper); int deleteBatchIds(@Param("coll") Collection<? extends Serializable> idList); int updateById(@Param("et") T entity); int update(@Param("et") T entity, @Param("ew") Wrapper<T> updateWrapper); T selectById(Serializable id); List<T> selectBatchIds(@Param("coll") Collection<? extends Serializable> idList); List<T> selectByMap(@Param("cm") Map<String, Object> columnMap); T selectOne(@Param("ew") Wrapper<T> queryWrapper); Integer selectCount(@Param("ew") Wrapper<T> queryWrapper); List<T> selectList(@Param("ew") Wrapper<T> queryWrapper); List<Map<String, Object>> selectMaps(@Param("ew") Wrapper<T> queryWrapper); List<Object> selectObjs(@Param("ew") Wrapper<T> queryWrapper); <E extends IPage<T>> E selectPage(E page, @Param("ew") Wrapper<T> queryWrapper); <E extends IPage<Map<String, Object>>> E selectMapsPage(E page, @Param("ew") Wrapper<T> queryWrapper);
}

Wrapper为条件查询构造器,QueryWrapper为Wrapper的一个实现方法。主要是用来进行多个where条件的拼接。

例如:

QueryWrapper<Student> queryWrapper = new QueryWrapper<>();
queryWrapper.gt("age", 10).eq("sex", "女"); //年龄大于10且性别为“女"
Wrapper中的方法 含义
ge
大于等于
gt
表示大于
le
小于等于
lt
小于
eq
等于
ne
不等于
between
范围 between("age",20,30); 年龄范围[20,30]

4、SpringBoot整合MybatisPlus实现增删改查的一个简单Demo

源码:https://gitee.com/wulinchun/mybatis-plus.git   (dev分支)

4.1、目录结构

4.2、代码

4.2.1、xml&yml配置

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.2.RELEASE</version>
<relativePath/>
</parent>
<groupId>org.example</groupId>
<artifactId>mybatis-plus</artifactId>
<version>1.0-SNAPSHOT</version> <properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--Mybatis-Plus -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.0</version>
</dependency>
<!--mybatis-plus 代码生成器-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.4.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
<scope>provided</scope>
</dependency>
<!--sqlserver依赖-->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
</dependency>
<!--mysql依赖-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.26</version>
</dependency> </dependencies> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
</plugins>
</build>
</project>

application.yml

server:
port: 8080 spring:
profiles:
active: dev #使用application-dev.yml里面的配置

application-dev.yml

server:
port: 8080
spring:
datasource:
name: mybatis_plus
url: jdbc:mysql://localhost:3306/mydb?serverTimezone=UTC&characterEncoding=utf8
username: root
password: 123456
driver-class-name: com.mysql.jdbc.Driver
mybatis:
mapper-locations: classpath:mapper/*.xml #注意:一定要对应mapper映射xml文件的所在路径
type-aliases-package: com.mybatisplus.entity # 注意:对应实体类的路径 mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #打印mybatis-plus的sql语句

ScoreMapper.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.mybatisplus.mapper.IScoreMapper"> </mapper>

StudentMapper.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.mybatisplus.mapper.IStudentMapper"> </mapper>

4.2.2、实体类

Score.java

package com.mybatisplus.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor; /**
* @author: wu linchun
* @time: 2021/6/6 11:34
* @description:
*/
@Data
@TableName("t_score")
@NoArgsConstructor
@AllArgsConstructor
public class Score {
@TableField("sno")
private int sno;
@TableField("subject")
private String subject;
@TableField("score")
private int score;
}

Student.java

package com.mybatisplus.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor; import java.io.Serializable; /**
* @author: Wu Linchun
* @date: 2021/06/04/10:25
* @Description:
**/
@Data
@TableName("t_student")
@NoArgsConstructor
@AllArgsConstructor
public class Student implements Serializable {
@TableId
@TableField("sno")
private int sno;
@TableField("sname")
private String sname;
@TableField("age")
private int age;
@TableField("sex")
private String sex;
@TableField("sclass")
private String sclass;
}
StudentScoreVO.java 注:该实体类为映射t_student表和t_score表联合查询的结果
package com.mybatisplus.entity.vo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor; import java.io.Serializable; /**
* @author: wu linchun
* @time: 2021/6/6 11:42
* @description:
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class StudentScoreVO implements Serializable {
@TableField("sno")
private int sno;
@TableField("sname")
private String sname;
@TableField("subject")
private String subject;
@TableField("score")
private int score;
}

4.2.3、接口&实现类

IScoreMapper.java
package com.mybatisplus.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mybatisplus.entity.Student;
import com.mybatisplus.entity.vo.StudentScoreVO;
import javafx.scene.control.Pagination;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component; import java.util.List; /**
* @description:
* @author: wu linchun
* @time: 2021/6/6 11:49
*/
@Component("iScoreMapper")
public interface IScoreMapper extends BaseMapper<StudentScoreVO> {
/**
* 获取学生成绩并分页显示
* @return
*/
@Select("select tst.sno,tst.sname,tsc.subject,tsc.score from t_student tst,t_score tsc where tst.sno=tsc.sno")
List<StudentScoreVO> getScore(); /**
* 分页显示学生成绩
* @param
* @return
*/
@Select("select tst.sno,tst.sname,tsc.subject,tsc.score from t_student tst,t_score tsc where tst.sno=tsc.sno")
IPage<StudentScoreVO> getByPage(Page<StudentScoreVO> studentScoreVOPage,QueryWrapper<StudentScoreVO> queryWrapper); @Select("select count(*) from t_student tst,t_score tsc where tst.sno=tsc.sno")
int getCount();
}
IStudentMapper.java
package com.mybatisplus.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mybatisplus.entity.Student;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Component; /**
* @author: Wu Linchun
* @date: 2021/06/04/14:48
* @Description:
**/
@Component("iStudentMapper")
public interface IStudentMapper extends BaseMapper<Student> {
}
IScoreService.java
package com.mybatisplus.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mybatisplus.entity.vo.StudentScoreVO;
import javafx.scene.control.Pagination; import java.util.List; /**
* @description:
* @author: wu linchun
* @time: 2021/6/6 11:55
*/ public interface IScoreService {
/**
*
* @return
*/
List<StudentScoreVO> getScore(); /**
*分页显示
* @param
* @return
*/
IPage<StudentScoreVO> getByPage(Page<StudentScoreVO> studentScoreVOPage, QueryWrapper<StudentScoreVO> queryWrapper); /**
*
* @return
*/
int getCount();
}
IStudentService.java
package com.mybatisplus.service;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mybatisplus.entity.Student;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository; import java.util.List; /**
* @author: Wu Linchun
* @date: 2021/06/04/14:02
* @Description:
**/ public interface IStudentService {
/**
* 根据唯一性主键进行查询 sno是唯一性主键
*
* @param sno
* @return
*/
Student getBySno(int sno); /**
* 查询全部
*
* @return
*/
List<Student> getAll(); /**
* 根据性别和年龄查询
*
* @param sex
* @param age
* @return
*/
List<Student> getBySexAge(String sex, int age); /**
* 范围&多条件查询
*
* @param age
* @return
*/
List<Student> getStudentsByScope(int age); /**
* 添加学生
*
* @param student
* @return
*/
int insertStudent(Student student); /**
* 根据指定条件删除
*
* @param sno
* @return
*/
int deleteBySno(int sno); /**
* 根据多个指定条件删除
*
* @param sclass
* @param sex
* @return
*/
int deleteBySclass_sex(String sclass, String sex); /**
* 更新
*
* @param student
* @return
*/
int updateStudent(Student student); /**
* 获取表中总记录数
* @return
*/
int getCount(); }
ScoreServiceImpl.java
package com.mybatisplus.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mybatisplus.entity.vo.StudentScoreVO;
import com.mybatisplus.mapper.IScoreMapper;
import com.mybatisplus.service.IScoreService;
import javafx.scene.control.Pagination;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service; import java.util.List; /**
* @author: wu linchun
* @time: 2021/6/6 11:56
* @description:
*/
@Service
public class ScoreServiceImpl implements IScoreService {
@Autowired
@Qualifier("iScoreMapper")
private IScoreMapper iScoreMapper; @Override
public List<StudentScoreVO> getScore() {
return iScoreMapper.getScore();
} @Override
public IPage<StudentScoreVO> getByPage(Page<StudentScoreVO> studentScoreVOPage, QueryWrapper<StudentScoreVO> queryWrapper) {
return iScoreMapper.getByPage(studentScoreVOPage, queryWrapper);
} @Override
public int getCount() {
return iScoreMapper.getCount();
}
}
StudentServiceImpl.java
package com.mybatisplus.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mybatisplus.entity.Student;
import com.mybatisplus.mapper.IStudentMapper;
import com.mybatisplus.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service; import java.util.HashMap;
import java.util.List;
import java.util.Map; /**
* @author: Wu Linchun
* @date: 2021/06/04/14:55
* @Description:
**/
@Service
public class StudentServiceImpl implements IStudentService { @Autowired
@Qualifier("iStudentMapper")
private IStudentMapper iStudentMapper; @Override
public Student getBySno(int sno) {
return iStudentMapper.selectById(sno);
} @Override
public List<Student> getAll() {
return iStudentMapper.selectList(null);
} @Override
public List<Student> getBySexAge(String sex, int age) {
Map<String, Object> map = new HashMap<>();
map.put("sex", sex);
map.put("age", age);
return iStudentMapper.selectByMap(map);
} @Override
public List<Student> getStudentsByScope(int age) {
QueryWrapper<Student> queryWrapper = new QueryWrapper<>();
//ge表示大于等于、gt表示大于、le表示小于等于、lt表示小于
//eq等于、ne不等于
//between范围 between("age",20,30); 年龄范围20~30
//查询年龄20-30范围 1.代表字段 2.代表开始值 3.代表结束值
/* queryWrapper.gt("age",age); queryWrapper.gt("age",10); //年龄大于10
queryWrapper.ge("age",10); //年龄大于等于10
queryWrapper.le("age",10); //年龄小于等于10
queryWrapper.lt("age",10); //年龄小于10
queryWrapper.eq("age",10); //年龄等于10
queryWrapper.ne("age",10); //年龄不等于10
queryWrapper.between("age",20,30); //年龄介于20~30之间*/
queryWrapper.gt("age", 10).eq("sex", "女"); //年龄大于10且性别为“女"
return iStudentMapper.selectList(queryWrapper); } @Override
public int insertStudent(Student student) {
return iStudentMapper.insert(student);
} @Override
public int deleteBySno(int sno) {
QueryWrapper<Student> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("sno", sno);
return iStudentMapper.delete(queryWrapper);
} /**
* 根据班级和性别删除
*
* @param sclass
* @param sex
* @return
*/
@Override
public int deleteBySclass_sex(String sclass, String sex) {
Map<String, Object> map = new HashMap<>();
map.put("sclass", sclass);
map.put("sex", sex);
return iStudentMapper.deleteByMap(map);
} @Override
public int updateStudent(Student student) {
QueryWrapper<Student> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("sno", student.getSno());
return iStudentMapper.update(student, queryWrapper);
} @Override
public int getCount() {
QueryWrapper<Student> queryWrapper=new QueryWrapper<>();
queryWrapper.eq("sex","男");
// return iStudentMapper.selectCount(null); //null为获取表中总记录数
return iStudentMapper.selectCount(queryWrapper); //获取指定条件的记录数
}
}

4.2.4、配置类

MybatisPlusConfig.java
package com.mybatisplus.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; /**
* @author: wu linchun
* @time: 2021/6/6 12:13
* @description: mybatis-plus分页插件配置
*/
@Configuration
public class MybatisPlusConfig {
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
} }

4.2.5、测试类

MyControllerTest.java
package com.mybatisplus.test;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mybatisplus.entity.Student;
import com.mybatisplus.entity.vo.StudentScoreVO;
import com.mybatisplus.service.IStudentService;
import com.mybatisplus.service.impl.ScoreServiceImpl;
import com.mybatisplus.service.impl.StudentServiceImpl;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration; import java.util.ArrayList;
import java.util.List;
import java.util.Map; /**
* @author: wu linchun
* @time: 2021/6/5 20:31
* @description:
*/
@RunWith(SpringRunner.class)
@SpringBootTest
//由于是Web项目,Junit需要模拟ServletContext,因此我们需要给我们的测试类加上@WebAppConfiguration。
@WebAppConfiguration
public class MyControllerTest {
@Autowired
@Qualifier("studentServiceImpl")
private StudentServiceImpl studentServiceImpl; @Autowired
@Qualifier("scoreServiceImpl")
private ScoreServiceImpl scoreServiceImpl; @Test
public void testAdd() {
int sno = 20160001;
for (int i = 0; i < 10; i++) {
Student student = new Student(sno++, "张三", 20, "男", "2016222");
if (studentServiceImpl.insertStudent(student) == 1) {
System.out.println("添加成功");
} else {
System.out.println("添加失败");
}
}
} @Test
public void testDeleteBySno() {
if (studentServiceImpl.deleteBySno(20160009) == 1) {
System.out.println("删除成功");
} else {
System.out.println("删除失败");
}
} @Test
public void testDeleteBySclass_sex() {
if (studentServiceImpl.deleteBySclass_sex("2016221", "男") == 1) {
System.out.println("删除成功");
} else {
System.out.println("删除失败");
}
} @Test
public void testGetAll() {
List<Student> studentList = new ArrayList<Student>();
studentList = studentServiceImpl.getAll();
for (Student student : studentList) {
System.out.println(studentList.toString());
}
} @Test
public void testGetStudentsByScope() {
List<Student> studentList = studentServiceImpl.getStudentsByScope(10);
for (Student student : studentList) {
System.out.println(studentList.toString());
}
} @Test
public void testUpdateStudent() {
Student student = new Student(20160010, "HHH", 20, "男", "2016222");
if (studentServiceImpl.updateStudent(student) == 1) {
System.out.println("更新成功");
} else {
System.out.println("更新失败");
}
} @Test
public void testGetBySno() {
Student student = studentServiceImpl.getBySno(20160003);
System.out.println(student.toString());
} @Test
public void testGetCount() {
System.out.println(studentServiceImpl.getCount());
} @Test
public void testGetScore() {
List<StudentScoreVO> studentScoreVOList = scoreServiceImpl.getScore();
for (StudentScoreVO studentScoreVO : studentScoreVOList) {
System.out.println(studentScoreVO.toString());
}
} @Test
public void testGetByPage() {
int curr = 0, size = 3;
while (curr <= scoreServiceImpl.getCount() / 3 + 1) {
Page<StudentScoreVO> page = new Page<>(curr, size);
System.out.println(curr + " " + size);
scoreServiceImpl.getByPage(page, null).getRecords().forEach(System.out::println);
curr++;
System.out.println("------------------------------------------------");
}
} }

由于在yml中增加了打印MybatisPlus的sql配置,因此执行时可以在控制台看到输出的MybatisPlus封装的sql语句。

5、参考资料

MyBatis Plus 简单介绍 - 知乎 (zhihu.com)

mybatis plus实现某种条件查询 - 谢世林 - 博客园 (cnblogs.com)

mybatis-plus的sql语句打印问题_猿,码的博客-CSDN博客_mybatisplus打印sql语句

mybatis-plus实现多表联查 - 白衣风云 - 博客园 (cnblogs.com)

MyBatis-Plus_分页查询_Gblfy_Blog-CSDN博客_mybatis-plus分页查询

Mybatis-plus中sql语句LT、LE、EQ、NE、GE、GT的意思 - 潘向福 - 博客园 (cnblogs.com)

Mybatis-plus实现数据库的增删改查操作的更多相关文章

  1. PHP程序中使用PDO对象实现对数据库的增删改查操作的示例代码

    PHP程序中使用PDO对象实现对数据库的增删改查操作(PHP+smarty) dbconn.php <?php //------------------------使用PDO方式连接数据库文件- ...

  2. python web.py操作mysql数据库,实现对数据库的增删改查操作

    使用web.py框架,实现对mysql数据库的增删改查操作: 该示例代码中连接的是本地数据库testdb,user表,表结构比较简单,只有两个字段:mobile和passwd,类型均为字符型 实际应用 ...

  3. TP5.1:数据库的增删改查操作(基于面向对象操作)

    我们现实中对数据库的增删改查操作,都是使用模型类进行操作的(表名::),也就是面向对象操作,只有底层的代码用的是数据库操作(Db::table('表名')) 下面我将贴出模型类进行的增删改查操作,通过 ...

  4. 通过jdbc连接MySql数据库的增删改查操作

    一.获取数据库连接 要对MySql数据库内的数据进行增删改查等操作,首先要获取数据库连接 JDBC:Java中连接数据库方式 具体操作如下: 获取数据库连接的步骤: 1.先定义好四个参数 String ...

  5. TP5.1:数据库的增删改查操作(基于数据库操作)

    1.在app/index/controller文件夹下创建一个文件,名为:Operation 注意:起名一定要避开关键字,例如:mysql,curd等等,如果使用关键字起名,会造成报错! 在Opera ...

  6. SSMybatis整合 --详细解读Mybatis对oracle数据库进行增删改查(一)

    Mybatis是现在主流的持久化层框架,与Hibernate不同的是,它鼓励程序员使用原声SQL语句对数据库进行操作.因此提供了非常灵活的功能.特别是当数据库同时访问数过多,需要进行优化时,使用sql ...

  7. greendao对SQLite数据库的增删改查操作

    利用greendao操作数据库时,都是以对象或者对象的list来进行增删改查的操作,操作的结果都是用一个list来接收的!!! 1.增加一条记录 Stu stu01=new Stu();stu01.s ...

  8. Django中ORM对数据库的增删改查操作

         前言 什么是ORM?  ORM(对象关系映射)指用面向对象的方法处理数据库中的创建表以及数据的增删改查等操作. 简而言之,就是将数据库的一张表当作一个类,数据库中的每一条记录当作一个对象.在 ...

  9. 【Mybatis】mybatis开启Log4j日志、增删改查操作

    Mybatis日志(最常用的Log4j) 官方网站http://www.mybatis.org/mybatis-3/zh/logging.html 1.在src目录下创建一个log4j.propert ...

  10. nodejs对mongodb数据库的增删改查操作(转载)

    首先要确保mongodb的正确安装,安装参照:http://docs.mongodb.org/manual/tutorial/install-mongodb-on-debian-or-ubuntu-l ...

随机推荐

  1. 计算机保研,maybe this is all you need(普通双非学子上岸浙大工程师数据科学项目)

    写在前面 9.28接收了拟录取通知,也终究是尘埃落定了,我人生的又一个阶段也终于结束.面对最终录取结果,或多或少会有所遗憾,但也还是基本达到了预期的目标了. 作为在今年严峻的保研形势下幸存的我,一直想 ...

  2. 华为路由器RIP路由协议配置命令

    RIP路由协议配置 rip 创建开启协议进程 network + ip 对指定网段接口使能RIP功能IP地址是与路由器直连的网段 debugging rip 1 查看RIP定期更新情况 termina ...

  3. 方法的重载(overload)

    1.定义:在同一个类中,允许存在一个以上的同名方法,只要它们的参数个数或者参数类型不同即可. "两同一不同":同一个类.相同方法名 参数列表不同:参数个数不同,参数类型不同 2.举 ...

  4. python渗透测试入门——基础的网络编程工具

    <Python黑帽子--黑客与渗透测试编程之道学习>这本书是我在学习安全的过程中发现的在我看来十分优秀的一本书,业内也拥有很高的评价,所以在这里将自己的学习内容分享出来. 1.基础的网络编 ...

  5. 基于数组或链表的学生信息管理系统(小学期C语言程序实训)

    1.基于数组的学生信息管理系统 实验内容: 编写并调试程序,实现学校各专业班级学生信息的管理.定义学生信息的结构体类型,包括:学号.姓名.专业.班级.3门成绩. 实验要求: (1) main函数:以菜 ...

  6. 将vue+nodejs项目部署到服务器上(完整版)

    1.后端使用express生成器 1.1.后台node项目部署 在node项目里安装cors依赖(跨域)npm install cors --save,在app.js文件中使用var cors = r ...

  7. 学习ASP.NET Core Blazor编程系列十——路由(上)

    学习ASP.NET Core Blazor编程系列一--综述 学习ASP.NET Core Blazor编程系列二--第一个Blazor应用程序(上) 学习ASP.NET Core Blazor编程系 ...

  8. Substring 在BCL和CLR里面搞了啥

    楔子 还是做点事情,不要那么散漫. 本文以简单的Substring(int startindex,int Length)函数为例,来递进下它在托管和非托管的一些行为. 以下均为个人理解,如有疏漏请指正 ...

  9. 用于数据科学的顶级 C/C++ 机器学习库整理

    用于数据科学的顶级 C/C++ 机器学习库整理 介绍和动机--为什么选择 C++ C++ 非常适合 动态负载平衡. 自适应缓存以及开发大型大数据框架 和库.Google 的MapReduce.Mong ...

  10. 记一次HTTPClient模拟登录获取Cookie的开发历程

    记一次HTTPClient模拟登录获取Cookie的开发历程 环境: ​ springboot : 2.7 ​ jdk: 1.8 ​ httpClient : 4.5.13 设计方案 ​ 通过新建一个 ...