Note that there are some explanatory texts on larger screens.

plurals
  1. POWhen transactionManager is not named "transactionManager"
    primarykey
    data
    text
    <p>I am trying Spring 3(.0.2.RELEASE) and JPA2 and Hibernate 3.5.1-Final... One thing upsets me is that spring seems only accept a transaction Manager named "transactionManager"</p> <p>If I don't name it "transactionManager" , Spring will throws <strong>NoSuchBeanDefinitionException: No bean named 'transactionManager'</strong> is defined.</p> <p>Here is my config :</p> <pre><code>&lt;context:component-scan base-package="destiny.data.mining"/&gt; &lt;context:annotation-config/&gt; &lt;bean id="miningEntityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt; &lt;property name="persistenceUnitName" value="mining"/&gt; &lt;/bean&gt; &lt;bean id="miningTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" &gt; &lt;property name="entityManagerFactory" ref="miningEntityManagerFactory"/&gt; &lt;/bean&gt; &lt;tx:advice id="txAdviceMining" transaction-manager="miningTransactionManager"&gt; &lt;tx:attributes&gt; &lt;tx:method name="get*" read-only="true"/&gt; &lt;tx:method name="save*" propagation="REQUIRED"/&gt; &lt;tx:method name="update*" propagation="REQUIRED"/&gt; &lt;tx:method name="delete*" propagation="REQUIRED"/&gt; &lt;tx:method name="*" propagation="SUPPORTS" read-only="true"/&gt; &lt;/tx:attributes&gt; &lt;/tx:advice&gt; &lt;aop:config&gt; &lt;aop:pointcut id="methods" expression="execution(* destiny.utils.AbstractDao+.*(..))"/&gt; &lt;aop:advisor advice-ref="txAdviceMining" pointcut-ref="methods"/&gt; &lt;/aop:config&gt; &lt;tx:annotation-driven transaction-manager="miningTransactionManager"/&gt; </code></pre> <p>In this config , an Entity Manager Factory is <strong>not</strong> necessarily named "entityManagerFactory" , and "txAdvice" is <strong>not</strong> necessarily named "txAdvice" , either. But I don't know why on earth Spring requires a transaction manager named "transactionManager" ?</p> <p><strong>Is there any way not to name a transaction manager "transactionManager" ?</strong> (I'm running multiple spring config files , so I try my best to avoid name-conflicting)</p> <p>test code :</p> <pre><code>@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations={"classpath:mining.xml"}) public class MiningPersonDaoTest { @Inject private EntityManagerFactory miningEntityManagerFactory; @Inject private MiningPersonDao miningPersonDao; @Transactional @Test public void testUpdate() { MiningPerson p = miningPersonDao.get(42L); p.setLocationName("OOXX"); miningPersonDao.update(p); System.out.println(p); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload