Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java EE 综合讨论区 » Hibernate  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 hql无法从数据库读到数据
c00lzhang





发贴: 20
积分: 0
于 2005-12-08 11:45 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我的代码如下:
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 + " ²»Î¨Ò»");
}
        
    }
}
问题是 不能从对应的表中得到数据 很是头痛 不知道什么地方不对。请高手看看。 本人先谢过了。。。


c00lzhang edited on 2005-12-08 15:19


搞笑QQ图片

话题树型展开
人气 标题 作者 字数 发贴时间
5761 hql无法从数据库读到数据 c00lzhang 2953 2005-12-08 11:45

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   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