Oracle在Mybatis中SQL语句的配置方法
程序员文章站
2022-04-23 20:04:20
数据库中有下划线的字段在实体中应采用驼峰命名法,如p_name对应pname,实例如下:
1.xml文件中sql语句配置(geteway.xml文件)
<...
数据库中有下划线的字段在实体中应采用驼峰命名法,如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语句的配置 ,希望对大家有所帮助
上一篇: 名将仆固怀恩在历史上究竟是个怎样的人?
推荐阅读
-
在oracle 数据库查询的select 查询字段中关联其他表的方法
-
idea mybatis配置log4j打印sql语句的示例
-
MSSQL批量替换语句 在SQL SERVER中批量替换字符串的方法
-
在oracle 数据库中查看一个sql语句的执行时间和SP2-0027错误
-
MyBatis3用log4j在控制台输出SQL的方法示例
-
详解一条sql语句在mysql中是如何执行的
-
在Oracle PL/SQL中游标声明中表名动态变化的方法
-
django配置连接数据库及原生sql语句的使用方法
-
在SQL Server中查询资料库的TABLE数量与名称的sql语句
-
Oracle中在pl/sql developer修改表的2种方法