sessionFactory.getCurrentSession() 事务文件: <?xml version=”1.0″ encoding=”UTF-8″?> <!– 开启AOP监听 只对当前配置文件有效 –> <!– 开启注解事务 只对当前配置文件有效 –> <bean id=”txManager” class=”org.springframework.orm.hibernate4.HibernateTransactionManager”> <tx:advice id=”txAdvice” transaction-manager=”txManager”> </beans> spring文件贴出部分代码: <bean id=”BaseDaoImp” class=”com.dao.BaseDaoImp”> 请哪位大侠教教 谢谢 |
|
20分 |
sessionFactory 用的是org.springframework.orm.hibernate4.LocalSessionFactoryBean 么?
是的话在hibernateProperties中加个配置: |
10分 |
|
这个试过了 ,加上了也还是抱着个错误 |
|
什么情况 没人知道吗?
|
|
50分 |
你的 sessionFactory 在哪里?
<bean name="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"></property> <property name="url" value="jdbc:mysql://192.168.1.121:3306/xsl"></property> <property name="username" value="root"></property> <property name="password" value="sa"></property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="annotatedClasses"> <list> <value>org.birdy.entity.Media</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="hibernate.query.factory_class"> org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory </prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.query.substitutions"> true ""T"", false ""F"" </prop> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="hibernate.current_session_context_class"> org.springframework.orm.hibernate4.SpringSessionContext </prop> </props> </property> </bean> |
<?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:context=”http://www.springframework.org/schema/context” xmlns:aop=”http://www.springframework.org/schema/aop” xsi:schemaLocation=”http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd ” default-autowire=”byName”> <!– auto register Processor –> <bean id=”dataSource” class=”org.apache.commons.dbcp.BasicDataSource” destroy-method=”close”> <!– hibernet –> <bean id=”sessionFactory” class=”org.springframework.orm.hibernate4.LocalSessionFactoryBean” <property name=”mappingResources”> <list> </list> <property name=”hibernateProperties”> </props> <bean id=”hibernateTemplate” class=”org.springframework.orm.hibernate4.HibernateTemplate”> <bean id=”BaseDaoImp” class=”com.dao.BaseDaoImp”> 基本上我都加了啊 为啥还报这个错误 |
|
好吧 是我是在事务切入的地方切入错了
|