另类的方法重载(小白的感慨)。
来源:互联网 发布:知乎共生关系 编辑:程序博客网 时间:2024/05/05 15:15
在做的项目中有个这样的方法。返回的是一个HashMap的集合。
public static HashMap<Object, Object> findTotalDuebillBalance(Database db,
String pcCode, String districtCode, String ccCode,
String studentName,String studentCode) throws Exception
{
String sql = "select d.studentCode,sum(duebillBalance) as totalDuebillBalance " +
"\n from duebill d" +
"\n left join StudentRelation sr on sr.studentCode=d.studentCode" +
"\n left join CountyCenter cc on cc.ccCode=sr.ccCode" +
"\n where 1=1";
if(!ccCode.equals(""))
sql += "\n and sr.ccCode='"+ccCode+"'";
else if(!districtCode.equals(""))
sql += "\n and exists (select 1 from CountyCenter cc where cc.ccCode=dd.deductCcCode and cc.pccCode like '"+districtCode+"%')";
else if(!pcCode.equals(""))
sql += "\n and sr.pcCode='"+pcCode+"'";
if(!studentName.equals(""))
sql += "\n and sr.studentName like '"+studentName+"%'";
if(!studentCode.equals(""))
sql += "\n and sr.studentCode = '"+studentCode+"'";
sql += "\n group by d.studentCode";
//执行查询
DataSet ds = db.executeQuery(sql);
HashMap<Object, Object> duebillMap = new HashMap<Object, Object>();
for (int i=0;i<ds.size();i++)
{
duebillMap.put(ds.getString(i, "studentCode"),ds.getDouble(i, "totalDuebillBalance"));
}
return duebillMap;
}
然后在bo中调用时候,传入参数时候。
第一种调用
DaoMyTest.findTotalDuebillBalance(db,"","","","","",studentCode);
第二种调用
DaoMyTest.findTotalDuebillBalance(db,pcCode,districtCode,ccCode,"");
--------------------------------------------------------------------------
这个和以前学习的时候学的方法重载很像,不过这种写法更倾向于简洁的应用,不至于写很多方法。业务理解上会有点困难。
- 另类的方法重载(小白的感慨)。
- 刚工作的小感慨!!
- 最近的一些小感慨
- 【分析】一种小堆(heap)溢出的另类利用方法
- 一种小堆(heap)溢出的另类利用方法
- 关于小虾米大学尾声的感慨
- 开博的一点小感慨
- 第一次做项目的一点点小感慨
- 停博一年以后的小感慨
- 奥运赛事的一点小感慨
- 关于一个小问题引发的感慨
- Vextractor 的另类破解方法
- sql的另类插入方法
- 文献查阅的另类方法
- 还原精灵的另类卸载方法
- 另类的二级域名实现方法
- 复制数据库的另类方法
- 获得FS的另类方法
- 笔试题CSDN经典blog网址收藏
- SQL Server 2008 压缩
- 国际化(2)
- c++中switch case 中关于变量定义问题
- 求集合中M个元素构成的子集问题
- 另类的方法重载(小白的感慨)。
- 蓝牙协议栈 第二季(Conceal)
- c# 多线程
- 系统初始化时kernel_init在内核态创建和运行应用程序以完成系统初始化
- 【php】如何对php代码进行优化?
- KEIL 中 RO RW ZI 段的含义
- iOS开源 框架
- 对日本经济制裁最有效的方法
- 在adobe reader中添加书签