Topic: hql无法从数据库读到数据 |
Print this page |
1.hql无法从数据库读到数据 | Copy to clipboard |
Posted by: c00lzhang Posted on: 2005-12-08 11:45 我的代码如下: package com.willstar.hnic.basedata.dao; import java.util.List; import java.util.Vector; import java.io.Serializable; import com.willstar.hnic.basedata.util.WillStarBaseDataException; import com.willstar.hnic.basedata.model.GasType; import com.willstar.hnic.base.dao.BaseDAOHibernate; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; import org.apache.log4j.Logger; public class GasTypeDAOimp extends BaseDAOHibernate implements GasTypeDAO { static Logger logger = Logger.getLogger(GasTypeDAOimp.class); /** * ÃèÊö:²éѯGasTypes * * @ param: * @ param:orderBy ÅÅÐòÊôÐÔ£¨for hql£© * @ param:sortType ÅÅÐò·½Ê½£¨asc or desc£© * @ Exception: * @ return model¼¯ºÏ */ public List findGasTypes(String code,String name,String orderBy,String sortType) { Object[] values = new Object[2]; values[0] = code; values[1] = name; String hql = "from GasType where code like ? and name like ? order by " + orderBy + " " + sortType + " "; return this.getHibernateTemplate().find(hql,values); } public GasType getByCode(String code) { Object[] values = new Object[1]; values[0] = code; List gasTypes = this.getHibernateTemplate().find("from GasType where code = ?",values); if(gasTypes.size() ==1) { GasType gasType = (GasType)gasTypes.get(0); return gasType; } else if(gasTypes.size() <1) { return null; } else { throw new WillStarBaseDataException(code + " ²»Î¨Ò»"); } } } 问题是 不能从对应的表中得到数据 很是头痛 不知道什么地方不对。请高手看看。 本人先谢过了。。。 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |