Spring.xml 配置信息
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://www.hibernate.org/xsd/hibernate-mapping hibernate-mapping-4.0.1.xsd
         http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
    <!-- 启动注解 -->
<context:annotation-config />
<context:component-scan base-package="com" />  <!-- 自动扫描所有注解该路径 -->
<!-- 加载配置信息properties -->
<context:property-placeholder location="classpath:/jdbc.properties" />
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.show_sql">${jdbc.showsql}</prop>
<prop key="hibernate.format_sql">${jdbc.format.sql}</prop>
<prop key="hibernate.dialect">${jdbc.dialect}</prop>
<prop key="hibernate.hbm2ddl.auto">${jdbc.hbm2ddl.auto}</prop>
</props>
</property>
<property name="packagesToScan">
<list>
<value>com.travelsky.**.model</value><!-- 扫描实体类,注解 -->
</list>
   </property>
</bean>
<!-- 配置事务管理 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
<property name="dataSource" ref="dataSource" />
</bean>
<!-- AOP 对Dao添加事务  -->
<aop:config>
    <aop:pointcut id="productServiceMethods" expression="execution(* com.travelsky.**.dao.*.*(..))"/>
    <aop:advisor advice-ref="txAdvice" pointcut-ref="productServiceMethods"/>
  </aop:config>
 
  <tx:advice id="txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
      <tx:method name="save*" propagation="REQUIRED"/>
      <tx:method name="update*" propagation="REQUIRED"/>
      <tx:method name="delete*" propagation="REQUIRED"/>
      <tx:method name="*" propagation="SUPPORTS" read-only="true"/>
    </tx:attributes>
  </tx:advice>

<!--配置数据源 -->
<bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource">
        <property name="driver" value="${jdbc.driverClassName}" />
<property name="driverUrl" value="${jdbc.url}" />
<property name="user" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="maximumConnectionCount" value="${proxool.maxConnCount}" />
<property name="minimumConnectionCount" value="${proxool.minConnCount}" />
        <property name="statistics" value="${proxool.statistics}" />
<property name="simultaneousBuildThrottle" value="${proxool.simultaneousBuildThrottle}" />
<property name="trace" value="${proxool.trace}" />
<property name="verbose" value="${proxool.verbose}" />
   </bean>
<!--  Dao模板,具体实现Dao继承此bean的配置,省去各个Dao的重复配置 -->
<bean id="daoTemplate" abstract="true">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- 测试 bean start -->
<bean id="studentDao" class="com.travelsky.demo.dao.impl.StudentDaoImpl" parent="daoTemplate"  />  
<bean id="studentService" class="com.travelsky.demo.service.impl.StudentServiceImpl" >
<property name="studentDao" ref="studentDao"/>
</bean>
<bean id="loginAction" class="com.travelsky.demo.web.LoginAction" >
<property name="studentService" ref="studentService" />
</bean>
<!-- 测试 bean end -->
</beans>基类Dao
/**
 * 保存
 */
public void save(T entity) {
System.out.println("GenericDao:" + entity);
// TODO Auto-generated method stub
// System.out.println(entity);
this.sessionFactory.getCurrentSession().save(entity);
}Hibernate4

解决方案 »

  1.   

    解决了没有?我也遇到这个问题,每次select语句的时候就会warn一下
      

  2.   

    唉  没解决呢,在那搁着呢 先做其它的 ,每次看个warn  真的很无语……
      

  3.   

    我也遇到了这个问题,不知道你们的会不会对程序运行有影响,我的在测试的时候操作一段时间就会卡死,没有抱任何错,就是这个warn一直存在,不知道是不是这个原因造成的,求大神啊
      

  4.   

    如果它找不到与ResultSet匹配的Statement就会报这个warning
    还没解决的bug,尚无证据显示会影响运行
      

  5.   

    这是hibernate本身的问题,我之前用 4.2.0.Final版本也出现这个警告,之后我更换成 4.2.2.Final版本,就没有问题了。
      

  6.   

    操了。我用的4.2.2.Final版也报这错。。郁闷,看着很不爽
    WARN: HHH000387: ResultSet's statement was not registered