小编Арт*_*нко的帖子

GenericDao:@Transactional再也没有工作了

我试图基于GenericDao制作web服务.我有Person Entity,我试图为GenericDao扩展的Entity制作dao.但是@Transactional注释不会打开事务:TransactionSynchronizationManager.isActualTransactionActive() = false

我找不到我想念的地方@Transactional.我试图@Transactional几乎随处可见.感觉就像注释不是从GenericDao继承的..

春天-config.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:context="http://www.springframework.org/schema/context"
      xmlns:tx="http://www.springframework.org/schema/tx"
      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/context
        http://www.springframework.org/schema/context/spring-context-3.0.xsd 
        http://www.springframework.org/schema/tx 
        http://www.springframework.org/schema/tx/spring-tx.xsd">

      <tx:annotation-driven transaction-manager="transactionManager"/>

      <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
        destroy-method="close">
        <property name="driverClassName" value="org.postgresql.Driver" />
        <property name="url" value="jdbc:postgresql://127.0.0.1:5432/test" />
        <property name="username" value="postgres" />
        <property name="password" value="postgress" />
      </bean>

      <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"></property>
        <property name="annotatedClasses">
        <list>
        <value>org.entity.nci.person.Person</value>
        </list>
        </property>
        <property name="hibernateProperties">
          <props>
            <prop 
             key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
            <prop key="hibernate.show_sql">true</prop>

          </props>
        </property>
        <property name="packagesToScan" value="com.byteslounge.spring.tx.model" />
      </bean>

      <bean id="transactionManager"
        class="org.springframework.orm.hibernate4.HibernateTransactionManager" …
Run Code Online (Sandbox Code Playgroud)

java spring hibernate

5
推荐指数
1
解决办法
477
查看次数

标签 统计

hibernate ×1

java ×1

spring ×1