I'm trying to extend JdoDaoSupport in a DAO using an Annotation based config and I am running into issues. My DAO is setup like this:
My applicationContext.xml looks like this:Code:@Repository @Transactional public class UserDao extends JdoDaoSupport { public void persist(Object object) { getJdoTemplate().makePersistent(object); } }
And I'm getting an exception complaining about how the PersistenceManagerFactory is not set. Here is the exception:Code:<?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:security="http://www.springframework.org/schema/security" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd"> <!-- Scans our classes for annotations which describe our beans and how they're wired together --> <context:component-scan base-package="com.llama.domain" /> <!-- Allows annotation based transactions with @Transactional see UserDao for example. --> <tx:annotation-driven /> <!-- BEGIN JDO Persitence Configuration --> <bean id="persistenceManagerFactory" class="org.springframework.orm.jdo.LocalPersistenceManagerFactoryBean"> <property name="persistenceManagerFactoryName" value="transactions-optional" /> </bean> <bean id="transactionManager" class="org.springframework.orm.jdo.JdoTransactionManager"> <property name="persistenceManagerFactory" ref="persistenceManagerFactory" /> </bean> <!-- END JDO Persitence Configuration --> </beans>
Apparently the setPersistenceManagerFactory method is never called with the annotation based config I am using. Do I have other choices beside just using an xml based config for these DAO classes?Code:Caused by: java.lang.IllegalArgumentException: persistenceManagerFactory or jdoTemplate is required at org.springframework.orm.jdo.support.JdoDaoSupport.checkDaoConfig(JdoDaoSupport.java:114) at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:44) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$5.run(AbstractAutowireCapableBeanFactory.java:1451) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1449) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1398) ... 31 more


Reply With Quote
