Oracle在Mybatis中SQL语句的配置方法
程序员文章站
2024-01-17 14:15:52
数据库中有下划线的字段在实体中应采用驼峰命名法,如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语句的配置 ,希望对大家有所帮助
上一篇: 安卓12硬件要求公布:内存至少6GB
下一篇: GGPO 街机无法连接之路由器设置篇
推荐阅读
-
Oracle在Mybatis中SQL语句的配置方法
-
在linux下写的mysql无法插入,sql语句在复制中变'脏'了.
-
这个坑,我裂开了!!!mybatis的mapper.xml文件中sql语句前后有注释掉的sql都会报错,那注释这个功能在这还有毛用???/捂脸/捂脸...
-
在MySQL数据库中执行SQL语句时的几个注意点_MySQL
-
php-mysql 问题笔记一——在命令行中可以执行的sql语句,无法从php页面页面执行!
-
关于Oracle的在Eclipse中操作的命令语句
-
在CRUD操作中与业务无关的SQL字段赋值的方法
-
在SQL 2012中使用和Oracle 一样的序列
-
Shell脚本中执行sql语句操作mysql的5种方法
-
在linux下写的mysql无法插入,sql语句在复制中变'脏'了.