日期:2014-05-19  浏览次数:20646 次

org.hibernate.HibernateException: No Session found for current thread
这是applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:aop="http://www.springframework.org/schema/aop" 
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans  
                           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
                           http://www.springframework.org/schema/tx  
                           http://www.springframework.org/schema/tx/spring-tx-3.0.xsd 
                           http://www.springframework.org/schema/aop  
                           http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
                              

<!-- 数据元配置 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
  <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
  <property name="url" value="jdbc:mysql://localhost:3306/callsystem"></property>
  <property name="username" value="root"></property>
  <property name="password" value="521958k42jv"></property>   
</bean>

<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
  <property name="dataSource" ref="dataSource"></property>
  <property name="mappingResources">
    <list>
      <value>/hbm/xml/Group/user.hbm.xml</value>
      <value>/hbm/xml/Group/userMap.hbm.xml</value>
      <value>/hbm/xml/Group/set_meal.hbm.xml</value>
      <value>/hbm/xml/Group/card.hbm.xml</value>
      <value>/hbm/xml/Group/history.hbm.xml</value>
      <value>/hbm/xml/Group/action.hbm.xml</value>
    </list>
  </property>
  <property name="hibernateProperties">
    <props>
      <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
      <!-- <prop key="hibernate.