为什么我的页面能跳转成功而在数据库中查不到数据? 希望大家帮帮忙

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【w87179128】截止到2008-07-04 12:56:45的历史汇总数据(不包括此帖):
    发帖的总数量:2                        发帖的总分数:25                       
    结贴的总数量:0                        结贴的总分数:0                        
    无满意结贴数:0                        无满意结贴分:0                        
    未结的帖子数:2                        未结的总分数:25                       
    结贴的百分比:0.00  %               结分的百分比:0.00  %                  
    无满意结贴率:---------------------无满意结分率:---------------------
    如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
      

  2.   

    你说得也太笼统了吧,估计是用hib却没有正确保存对象
      

  3.   

    我数据库错做的类是myeclipse自己生成的啊。。
    package com.wang.hibernate.DAO;import java.util.List;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    import org.hibernate.LockMode;
    import org.hibernate.Query;
    import org.hibernate.criterion.Example;import com.wang.hibernate.Userinfo;
    public class UserinfoDAO extends BaseHibernateDAO {
    private static final Log log = LogFactory.getLog(UserinfoDAO.class);
    // property constants
    public static final String USERNAME = "username";
    public static final String PASSWORD = "password";
    public static final String SEX = "sex";
    public static final String TEL = "tel";
    public static final String EMAIL = "email";
    public static final String ROLE = "role";
    public static final String QQ = "qq"; public void save(Userinfo transientInstance) {
    log.debug("saving Userinfo instance");
    try {
    getSession().save(transientInstance);
    log.debug("save successful");
    } catch (RuntimeException re) {
    log.error("save failed", re);
    throw re;
    }
    } public void delete(Userinfo persistentInstance) {
    log.debug("deleting Userinfo instance");
    try {
    getSession().delete(persistentInstance);
    log.debug("delete successful");
    } catch (RuntimeException re) {
    log.error("delete failed", re);
    throw re;
    }
    } public Userinfo findById(java.lang.Integer id) {
    log.debug("getting Userinfo instance with id: " + id);
    try {
    Userinfo instance = (Userinfo) getSession().get(
    "com.wang.hibernate.Userinfo", id);
    return instance;
    } catch (RuntimeException re) {
    log.error("get failed", re);
    throw re;
    }
    } public List findByExample(Userinfo instance) {
    log.debug("finding Userinfo instance by example");
    try {
    List results = getSession().createCriteria(
    "com.wang.hibernate.Userinfo")
    .add(Example.create(instance)).list();
    log.debug("find by example successful, result size: "
    + results.size());
    return results;
    } catch (RuntimeException re) {
    log.error("find by example failed", re);
    throw re;
    }
    } public List findByProperty(String propertyName, Object value) {
    log.debug("finding Userinfo instance with property: " + propertyName
    + ", value: " + value);
    try {
    String queryString = "from Userinfo as model where model."
    + propertyName + "= ?";
    Query queryObject = getSession().createQuery(queryString);
    queryObject.setParameter(0, value);
    return queryObject.list();
    } catch (RuntimeException re) {
    log.error("find by property name failed", re);
    throw re;
    }
    } public List findByUsername(Object username) {
    return findByProperty(USERNAME, username);
    } public List findByPassword(Object password) {
    return findByProperty(PASSWORD, password);
    } public List findBySex(Object sex) {
    return findByProperty(SEX, sex);
    } public List findByTel(Object tel) {
    return findByProperty(TEL, tel);
    } public List findByEmail(Object email) {
    return findByProperty(EMAIL, email);
    } public List findByRole(Object role) {
    return findByProperty(ROLE, role);
    } public List findByQq(Object qq) {
    return findByProperty(QQ, qq);
    } public List findAll() {
    log.debug("finding all Userinfo instances");
    try {
    String queryString = "from Userinfo";
    Query queryObject = getSession().createQuery(queryString);
    return queryObject.list();
    } catch (RuntimeException re) {
    log.error("find all failed", re);
    throw re;
    }
    } public Userinfo merge(Userinfo detachedInstance) {
    log.debug("merging Userinfo instance");
    try {
    Userinfo result = (Userinfo) getSession().merge(detachedInstance);
    log.debug("merge successful");
    return result;
    } catch (RuntimeException re) {
    log.error("merge failed", re);
    throw re;
    }
    } public void attachDirty(Userinfo instance) {
    log.debug("attaching dirty Userinfo instance");
    try {
    getSession().saveOrUpdate(instance);
    log.debug("attach successful");
    } catch (RuntimeException re) {
    log.error("attach failed", re);
    throw re;
    }
    } public void attachClean(Userinfo instance) {
    log.debug("attaching clean Userinfo instance");
    try {
    getSession().lock(instance, LockMode.NONE);
    log.debug("attach successful");
    } catch (RuntimeException re) {
    log.error("attach failed", re);
    throw re;
    }
    }
    }
      

  4.   

    这个是我的类
    package com.wang.struts.action;import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;import com.wang.hibernate.Userinfo;
    import com.wang.hibernate.DAO.UserinfoDAO;
    import com.wang.struts.form.RegistForm;public class RegistAction extends Action {
    /*
     * Generated Methods
     */
          UserinfoDAO  userinfoDao;
     
    public UserinfoDAO getUserinfoDao() {
    return userinfoDao;
    }
    public void setUserinfoDao(UserinfoDAO userinfoDao) {
    this.userinfoDao = userinfoDao;
    } public ActionForward execute(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response) {
    RegistForm  regist = (RegistForm)form;
    Userinfo userinfo =new Userinfo();
    userinfo.setUserid(regist.getUserid());
            userinfo.setUsername(regist.getUsername());
            userinfo.setPassword(regist.getPassword());
            userinfo.setSex(regist.getSex());
            userinfo.setEmail(regist.getEmail());
            userinfo.setRole(regist.getRole());
            userinfo.setTel(regist.getTel());
            userinfo.setQq(regist.getQq());
               userinfoDao.save(userinfo);
    return mapping.findForward("reg_suc");
    }
    }
      

  5.   

    这么说吧,你要保存的对象在hib中根本不存在,你要hib怎么保存?应该先把这个对象先找出来再updata,应该就是这种错误
      

  6.   

    还有一种情况就是id是自增的,但是xml中设置错误了
      

  7.   

    我的userid 设置的increment 但是在页面上并没有获得他。。该怎么做呀?
      

  8.   

    在对象xml里加入<generator class="identity" />
    例子id name="unitId" type="java.lang.Integer">
                <column name="Unit_id" />
                <generator class="identity" />