IMPL方法实现

//  这个方法是通过ID修改数据

如果得到结果大于0 表明结果有重复

如果得到结果小于0 表明结果正确

@Override
public boolean checkVersion(Integer id, Integer verString,String positionNum) {
// TODO Auto-generated method stub
//
// return this.etlextractvalueIDao.getEm().createQuery("from Etlextractposition where id!=?1 and versionNum=?2").setParameter(1, id)
// .setParameter(2, verString).getResultList().size()>0?true:false;
List list = this.etlextractpositionIDao.query("from Etlextractposition e where e.id!='"+id+"' and e.versionNum= '"+verString+"' and positionNum= '"+positionNum+"'");
if(list.size()>0){
System.out.println(list.size());
return true;
}else{
return false;
}
}

//  这个方法是通过条件插入数据

如果得到结果大于0 表明结果有重复

如果得到结果小于0 表明结果正确

@Override
public boolean checkVersion2(Integer verString,String positionNum){
List list = this.etlextractpositionIDao.query("from Etlextractposition e where e.versionNum= '"+verString+"' and positionNum= '"+positionNum+"'");
// .query("from LcUser l where l.realnameLc='"+name+"' and l.idLc != '" +id+ "'");
if(list.size()>0){
System.out.println(list.size());
return true;
}else{
return false;
}
}

ACTION 中方法调用

/*
* 添加一条数据方法
*/
public void AddEtlExtractPositionInfo(){
int code = Integer.parseInt(get("code").toString());
this.getmenu(code, this.getRequest());
System.out.println("AddEtlExtractPositionInfo code=--->"+code);

Etlextractposition ep = new Etlextractposition();
// this.copyPropertiesToBean(ep);
// String id = entity.getId().toString();
// System.out.println("id---->"+ id);
// String versionString = entity.getVersionNum().toString();
// System.out.println("versionString---->"+ versionString);

// entity.setId()
// entity.setPositionNum(get("positionNum")!= null?get("positionNum").toString():null);
// entity.setClasstype(get("classtype")!= null?Integer.parseInt(get("classtype").toString()):null);
// entity.setVersionNum(get("versionNum")!= null?Integer.parseInt(get("versionNum").toString()):null);
// entity.setOrderNum(get("orderNum")!= null?Integer.parseInt(get("orderNum").toString()):null);
// entity.setType(get("type")!=null?Integer.parseInt(get("type").toString()):null);
// entity.setMeth(get("meth")!=null?Integer.parseInt(get("meth").toString()):null);

// StringBuffer sBuffer = new StringBuffer("");
Integer verString = Integer.parseInt(get("versionNum").toString());
String positionNum = get("positionNum").toString();

if(this.etlService.checkVersion2(verString,positionNum)){
out.print("<script>alert('添加失败,位置信息不可重复!');window.history.go(-1);</script>");
}else{
ep.setPositionNum(get("positionNum").toString());
ep.setClasstype(get("classtype")!= ""?Integer.parseInt(get("classtype").toString()):null);
ep.setVersionNum(get("versionNum")!= ""?Integer.parseInt(get("versionNum").toString()):null);
ep.setOrderNum(get("orderNum")!= ""?Integer.parseInt(get("orderNum").toString()):null);
ep.setType(get("type")!=""?Integer.parseInt(get("type").toString()):null);
ep.setMeth(get("meth")!=""?Integer.parseInt(get("meth").toString()):null);

if(ep != null || !("".equals(ep))){
this.EtlextractpositionDao.insert(ep);
out.print("<script>alert('添加成功!');if(window!=parent){parent.document.getElementById('popCloseBox').click();" +
"parent.frames['ovfirame'].location='../CheckAction/ListEtlExtractPositionOfAll.action?code="+code+"'}; </script>");
}else{
out.print("<script>alert('添加失败!');window.history.go(-1);</script>");
}
}
}

/*
* 通过ID修改提取位置表信息
*/
public void ModifyExtractPositionById(){
int code = Integer.parseInt(get("code").toString());
Integer id = Integer.parseInt(get("id").toString());
Integer verString = Integer.parseInt(get("versionNum").toString());
String positionNum = get("positionNum").toString();

System.out.println("checkVersion--》 ");
System.out.println("checkVersion--》 "+id);
System.out.println("checkVersion--》 "+verString);
System.out.println("checkVersion--》 "+positionNum);

if(this.etlService.checkVersion(id,verString,positionNum)){
System.out.println("checkVersion--》2 ");
System.out.println("checkVersion--》2 "+id);
System.out.println("checkVersion--》2 "+verString);
System.out.println("checkVersion--》2 "+positionNum);
out.print("<script>alert('添加失败,位置信息不可重复!');window.history.go(-1);</script>");
out.close();
}else{
System.out.println("checkVersion--》3 ");
System.out.println("checkVersion--》3 "+id);
System.out.println("checkVersion--》3 "+verString);

// 获得ID 查处出实体
Etlextractposition ep = this.etlService.QueryExtractPositionById(id.toString());
// ep.setId(get("id"));
// 获得页面更新的数据显示在页面上
ep.setPositionNum(get("positionNum").toString());
ep.setClasstype(get("classtype")!= ""?Integer.parseInt(get("classtype").toString()):null);
ep.setVersionNum(get("versionNum")!= ""?Integer.parseInt(get("versionNum").toString()):null);
ep.setOrderNum(get("orderNum")!= ""?Integer.parseInt(get("orderNum").toString()):null);
ep.setType(get("type")!=""?Integer.parseInt(get("type").toString()):null);
ep.setMeth(get("meth")!=""?Integer.parseInt(get("meth").toString()):null);

// ep.setType(get("type")!=null?Integer.parseInt(get("type").toString()):null);
// ep.setType(get("type")!=null?Integer.parseInt(get("type").toString()):0);
// ep.setMeth(get("meth")!=""?Integer.parseInt(get("meth").toString()):0);
// ep.setMeth(get("meth")!=""?Integer.parseInt(get("meth").toString()):null);

if(ep.getId() != null){
this.EtlextractpositionDao.update(ep);
out.print("<script>alert('保存成功!');if(window!=parent){parent.document.getElementById('popCloseBox').click();" +
"parent.frames['ovfirame'].location='../CheckAction/ListEtlExtractPositionOfAll.action?code="+code+"'}; </script>");
}else{
out.print("<script>alert('保存失败!请重新输入');window.history.go(-1);</script>");
}

}
// this.etlService.checkVersion(id,verString)

// String positionNum = get("positionNum").toString();
//
// System.out.println("ModifyExtractPositionById id=--->"+id);
// System.out.println("ModifyExtractPositionById code=--->"+code);
// Etlextractposition ep = new Etlextractposition();
// ep = this.etlService.QueryExtractPositionById(id);
//// this.copyPropertiesToBean(ep);
// if(get("id").toString()!="" || !("".equals(get("id").toString()))){
// ep.setId(Integer.parseInt(get("id").toString()));
// System.out.println(get("id").toString());
// }
// if(get("positionNum").toString()!="" || !("".equals(get("positionNum").toString()))){
// ep.setPositionNum(get("positionNum").toString());
// System.out.println(get("positionNum").toString());
// }
// if(get("classtype").toString()!="" || !("".equals(get("classtype").toString()))){
// ep.setClasstype(Integer.parseInt(get("classtype").toString()));
// }
// if(get("versionNum").toString()!="" || !("".equals(get("versionNum").toString()))){
// ep.setVersionNum(Integer.parseInt(get("versionNum").toString()));
// }
// if(get("orderNum").toString()!="" ||!( "".equals(get("orderNum").toString()))){
// ep.setOrderNum(Integer.parseInt(get("orderNum").toString()));
// }
// if(get("type").toString()!="" || !("".equals(get("type").toString()))){
// ep.setType(Integer.parseInt(get("type").toString()));
// System.out.println(get("type").toString());
// }
// if(get("meth").toString()!="" || !("".equals(get("meth").toString()))){
// ep.setMeth(Integer.parseInt(get("meth").toString()));
// }
}

唯一性校验 impl 和 action的更多相关文章

  1. 使用AJAX实现用户名的唯一性校验(注册界面)-JAVA(新手)

    (1)实现用户名的唯一性校验 所需要准备的: Servlet 注册界面的JSP 接口和实现类 所需要的接口和实现类: 接口: /* * 用户注册 * 账号的唯一性校验,需要传参(username) * ...

  2. struts2:数据校验,通过Action中的validate()方法实现校验,图解

    根据输入校验的处理场所的不同,可以将输入校验分为客户端校验和服务器端校验两种.服务器端验证目前有两种方式: 第一种 Struts2中提供了一个com.opensymphony.xwork2.Valid ...

  3. struts2:数据校验,通过Action中的validate()方法实现校验(续:多业务方法时的不同验证处理)

    前文:struts2:数据校验,通过Action中的validate()方法实现校验,图解 如果定义的Action中存在多个逻辑处理方法,且不同的处理逻辑可能需要不同的校验规则,在这种情况下,就需要通 ...

  4. C#实现请求唯一性校验支持高并发

    使用场景描述: 网络请求中经常会遇到发送的请求,服务端响应是成功的,但是返回的时候出现网络故障,导致客户端无法接收到请求结果,那么客户端程序可能认为判断为网络故障,而重复发送同一个请求.当然如果接口中 ...

  5. SQL 建立多个字段唯一性校验

    由于在做压力测试,同一时间占用的问题. 两个用户同时下同一时间的订单,需要增加校验,第一个能保存的用户保存,第二个就不能让保存了. 问题是通过代码,怎么都做不到毫秒级校验,所以解决办法就只能是通过数据 ...

  6. Laravel 校验规则之字段值唯一性校验

    版权声明:本文为博主原创文章,未经博主允许不得转载. 目录(?)[+] laravel validator unique 'name' => 'required|unique:test,disp ...

  7. struts_20_对Action中所有方法、某一个方法进行输入校验(基于XML配置方式实现输入校验)

    第01步:导包 第02步:配置web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app ...

  8. struts2视频学习笔记 22-23(基于XML配置方式实现对action的所有方法及部分方法进行校验)

    课时22 基于XML配置方式实现对action的所有方法进行校验   使用基于XML配置方式实现输入校验时,Action也需要继承ActionSupport,并且提供校验文件,校验文件和action类 ...

  9. Struts2笔记——Action校验器

    在struts2中,我们可以实现对action的所有方法进行校验或者对action的指定方法进行校验.  对于输入校验struts2提供了两种实现方法: 1.采用手工编写代码实现. 2.基于XML配置 ...

随机推荐

  1. luogu2633 Count on a tree

    主席树放到树上而已 #include <algorithm> #include <iostream> #include <cstdio> using namespa ...

  2. Jmeter用于接口测试中,关联如何实现

    Jmeter用于接口测试时,后一个接口经常需要用到前一次接口返回的结果,应该如何获取前一次请求的结果值,应用于后一个接口呢,拿一个登录的例子来说明如何获取. 1.打开jmeter, 使用的3.3的版本 ...

  3. python019 Python3 File(文件) 方法

    file 对象使用 open 函数来创建,下表列出了 file 对象常用的函数: 序号 方法及描述 1 file.close() 关闭文件.关闭后文件不能再进行读写操作. 2 file.flush() ...

  4. OO第二次作业

    第一次作业: 由于第一次作业的调度较为简单,采用FIFO策略,以及不支持捎带功能,因此我的第一次电梯作业并没有设置单独的调度器,而会直接将任务交给电梯,电梯进行调度策略也仅为先运动到people的In ...

  5. css装饰文本框input

    在web程序前端页面中,<input>恐怕是用的最多的html元素了,各个需要录入信息的场合都会用到它,一般都会用css来修饰一下使得它更好看. 原始的不加修饰的文本框像下面,有些单调,页 ...

  6. HDU1166-敌兵布阵,线段数模板题~~

    敌兵布阵 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submi ...

  7. BZOJ 1924: [Sdoi2010]所驼门王的宝藏 【tarjan】

    Description 在宽广的非洲荒漠中,生活着一群勤劳勇敢的羊驼家族.被族人恭称为“先 知”的Alpaca L. Sotomon 是这个家族的领袖,外人也称其为“所驼门王”.所 驼门王毕生致力于维 ...

  8. mybatis使用步骤

    1.创建config.xml文件.设置环境.数据源等: 2.设置mapper.xml文件.写sql:下面图中的resultType属性经常会替换为resultMap,不过需要加入<resultM ...

  9. CodeIgniter框架的缓存原理分解

    用缓存的目的:(手册上叙述如下,已经写得很清楚了) Codeigniter 支持缓存技术,以达到最快的速度. 尽管CI已经相当高效了,但是网页中的动态内容.主机的内存CPU 和数据库读取速度等因素直接 ...

  10. ibatis中的xml配置文件

    <?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE sqlMap PUBLIC "-/ ...