public Object get(String entityName, Serializable id)
        throws HibernateException
    {
        LoadEvent event;
        boolean success;
        event = new LoadEvent(id, entityName, false, this);
        success = false;
        Object obj;
        fireLoad(event, LoadEventListener.GET);
        success = true;
        obj = event.getResult();
        afterOperation(success);
        return obj;
        Exception exception;  //为啥Return后面还能写东西还不出错?
        exception;            //上面都已经定义了exception 这里就写了个exception;是啥意思.为啥没出错?
        afterOperation(success);
        throw exception;
    }

解决方案 »

  1.   

    对lz说的这是Hibernate源码表示严重怀疑
    很明显这应该是实现Session接口的get方法嘛。SessionImpl中的get不会这么写吧!虽然实现功能没错 但这代码也太业余了吧!
    问题:
    为啥Return后面还能写东西还不出错?
    上面都已经定义了exception 这里就写了个exception;是啥意思.为啥没出错?Return后不能写东东,还有你说得那个exception没啥意思  肯定有错。
    lz是不是看的.class源码啊!!!!get方法修改下 这样写就不会不明白了public Object get(String entityName, Serializable id) throws HibernateException {
    LoadEvent event = new LoadEvent(id, entityName, false, this);
    boolean success = false;
    try {
    fireLoad(event, LoadEventListener.GET);
    success = true;
    return event.getResult();
    }
    finally {
    afterOperation(success);
    }
    }