gpt4 book ai didi

Oracle在Mybatis中SQL语句的配置方法

转载 作者:qq735679552 更新时间:2022-09-29 22:32:09 28 4
gpt4 key购买 nike

CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.

这篇CFSDN的博客文章Oracle在Mybatis中SQL语句的配置方法由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.

数据库中有下划线的字段在实体中应采用驼峰命名法,如P_NAME对应pName,实例如下:

1.XML文件中SQL语句配置(Geteway.xml文件) 。

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?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.soecode.hbdw.gateway.dao.GatewayDao" >
  <cache></cache>
  <! -- 目的:为dao接口方法提供sql语句配置 -->
  < select id= "queryById" resultType= "Gateway" parameterType= "int" >
  <! -- 具体的sql -->
  SELECT
    *
  FROM
   P_GATEWAY
  WHERE
   GATEWAY_ID = #{gatewayId}
  </ select >
  < select id= "queryByName" resultType= "Gateway" parameterType= "java.lang.String" >
  <! -- 具体的sql -->
  SELECT
   *
  FROM
   P_GATEWAY
  WHERE
   GATEWAY_NAME=#{gatewayName}
  </ select >
  < delete id= "delGateway" parameterType= "java.lang.Integer" >
    DELETE
    FROM
    P_GATEWAY
    WHERE
    GATEWAY_ID = #{gatewayId}
  </ delete >
  < update id= "updateGateway" >
  <! -- ignore 主键冲突,报错 -->
    UPDATE P_GATEWAY
    SET
    GATEWAY_NAME= #{gatewayName},
    GATEWAY_NUM= #{gatewayNum},
    GATEWAY_NATURE= #{gatewayNature},
    GATEWAY_SUPPLY= #{gatewaySupply},
    REMARK= #{remark}
    WHERE
    GATEWAY_ID = #{gatewayId}
  </ update >
</mapper>

2.entity实体配置(Gateway.java文件) 。

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.soecode.hbdw.gateway.entity;
import java.io. Serializable ;
import java.util. Date ;
public class Gateway implements Serializable {
  /**
  *
  */
  private static final long serialVersionUID = 1L;
  private int gatewayId;
  private String gatewayName;
  private String gatewayNum;
  private String gatewayNature;
  private String gatewaySupply;
  private String remark;
  public int getGatewayId() {
  return gatewayId;
  }
  public void setGatewayId( int gatewayId) {
  this.gatewayId = gatewayId;
  }
  public String getGatewayName() {
  return gatewayName;
  }
  public void setGatewayName(String gatewayName) {
  this.gatewayName = gatewayName;
  }
  public String getGatewayNum() {
  return gatewayNum;
  }
  public void setGatewayNum(String gatewayNum) {
  this.gatewayNum = gatewayNum;
  }
  public String getGatewayNature() {
  return gatewayNature;
  }
  public void setGatewayNature(String gatewayNature) {
  this.gatewayNature = gatewayNature;
  }
  public String getGatewaySupply() {
  return gatewaySupply;
  }
  public void setGatewaySupply(String gatewaySupply) {
  this.gatewaySupply = gatewaySupply;
  }
  public String getRemark() {
  return remark;
  }
  public void setRemark(String remark) {
  this.remark = remark;
  }
  public static long getSerialversionuid() {
  return serialVersionUID;
  }
  @Override
  public String toString() {
  return "Gateway [gatewayId=" + gatewayId + ", gatewayName="
   + gatewayName + ", gatewayNum=" + gatewayNum
   + ", gatewayNature=" + gatewayNature + ", gatewaySupply="
   + gatewaySupply + ", remark=" + remark + "]" ;
  }
}

以上所述是小编给大家介绍的Oracle在Mybatis中SQL语句的配置 ,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的! 。

原文链接:http://blog.csdn.net/jnx1142410525/article/details/63252802 。

最后此篇关于Oracle在Mybatis中SQL语句的配置方法的文章就讲到这里了,如果你想了解更多关于Oracle在Mybatis中SQL语句的配置方法的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com