• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

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

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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

1.XML文件中SQL语句配置(Geteway.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.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文件)

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语句的配置 ,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
为什么MySQL 使用timestamp可以无视时区问题.发布时间:2022-02-08
下一篇:
Windows安装压缩版MongoDB的教程发布时间:2022-02-08
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap