我跑代码,一步步调试的时候,是有问题的。 为什么啊?

hibernate中的org.hibernate.loader.custom.CustomLoader.java中是否有个BUG ? 如果有,麻烦在hibernate搞个BUG上去,不会英文描述。

protected void autoDiscoverTypes(ResultSet rs) {     

    try {     

        Metadata metadata = new Metadata( getFactory(), rs );     

        List aliases = new ArrayList();     

        List types = new ArrayList();     

    

        rowProcessor.prepareForAutoDiscovery( metadata );     

    

        for ( int i = 0; i < rowProcessor.columnProcessors.length; i++ ) {     

            rowProcessor.columnProcessors[i].performDiscovery( metadata, types, aliases );     

        }     

        //======================bug处=============================  

        // resultTypes的设值是有问题的,应该是将types中     

        // 的数据放入resultTypes,而不是直接赋值。     

        resultTypes = ArrayHelper.toTypeArray( types );     

        transformerAliases = ArrayHelper.toStringArray( aliases );     

    }     

    catch ( SQLException e ) {     

        throw new HibernateException( "Exception while trying to autodiscover types.", e );     

    }     

}    



我用的Hibernate是3.2.7.ga,我下过几个版本的源码,这段都是一样的。 

<dependency>  

    <groupId>org.hibernate</groupId>  

    <artifactId>hibernate</artifactId>  

    <version>3.2.7.ga</version>  

</dependency>  


心有法竹
浏览 149回答 2
2回答

慕盖茨4494581

给你一段我的代码package&nbsp;com.s2sh.dao.impl; &nbsp; &nbsp;&nbsp;import&nbsp;java.util.List; &nbsp; &nbsp; &nbsp;import&nbsp;org.springframework.orm.hibernate3.support.HibernateDaoSupport; &nbsp; &nbsp; &nbsp;&nbsp;import&nbsp;com.s2sh.dao.UserDao;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;import&nbsp;com.s2sh.mobel.User; &nbsp; &nbsp; &nbsp;&nbsp;public&nbsp;class&nbsp;UserDaoImpl&nbsp;extends&nbsp;HibernateDaoSupport&nbsp;implements&nbsp;UserDao{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//用户登录&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;public&nbsp;User&nbsp;findUser(User&nbsp;user)&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;try{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; String&nbsp;hql="from&nbsp;User&nbsp;where&nbsp;name=?&nbsp;and&nbsp;password=?";&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;List&nbsp;list&nbsp;=&nbsp;(List)&nbsp;this.getHibernateTemplate().find(hql,new&nbsp;String[]{user.getName(),user.getPassword()});&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if(list.size()>=1){&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return&nbsp;(User)list.get(0);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return&nbsp;null;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }catch&nbsp;(Exception&nbsp;e)&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;e.printStackTrace();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return&nbsp;null;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;

交互式爱情

直接用hibernate tomplate
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

MySQL
Java