读书人

【惯用需求收集】数据库交互类

发布时间: 2012-08-27 21:21:57 作者: rapoo

【常用需求收集】数据库交互类

1、查询是否存在此编号或名称,存在与不存在,建议用select count(*) from ....

?

例:

hql = "select count(*) from BasePipeline";                                                int count = (Integer) HibernateWrapper.queryOneObject(hql);                    if (count == 0) {// 是否子节点,open表示叶子,close表示不是叶子                        childJson.put("state", "open");                    } else if(count == 1){                        //**********                    } else{                        childJson.put("state", "closed");                    }
?

读书人网 >其他数据库

热点推荐