Hi guys,
I am new to appfuse 2 and just download a copy to try out and also trying
the "Using Hibernate" tutorial at
http://appfuse.org/display/APF/Using+Hibernate.
Under the section "Register a personDao bean definition", if I put in the
following into applicationContext-dao.xml:
<bean id="personDao"
class="org.appfuse.dao.hibernate.GenericDaoHibernate">
<constructor-arg value="org.appfuse.tutorial.model.Person"/>
</bean>
I will get the following error when I run mvn test -Dtest=PersonDaoTest
-Dsurefire.useFile=false:
Caused by: org.springframework.beans.factory.BeanCreationException: Could
not autowire field: private org.appfuse.dao.Pe
rsonDao org.appfuse.dao.PersonDaoTest.personDao; nested exception is
org.springframework.beans.factory.BeanCreationExcep
tion: Error creating bean with name 'personDao' defined in class path
resource [applicationContext-dao.xml]: 1 construct
or arguments specified but no matching constructor found in bean 'personDao'
(hint: specify index and/or type arguments
for simple parameters to avoid type ambiguities)
at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.injec
t(AutowiredAnnotationBeanPostProcessor.java:435)
at
org.springframework.beans.factory.annotation.InjectionMetadata.injectFields(InjectionMetadata.java:105)
at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiati
on(AutowiredAnnotationBeanPostProcessor.java:240)
... 23 more
However, if I remove it, I got the below exception:
Caused by: org.hibernate.hql.ast.QuerySyntaxException: Person is not mapped
[from Person where lastName=?]
at
org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:181)
at
org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:110)
at
org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:93)
at
org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:277)
at
org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3056)
at
org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2945)
at
org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
at
org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
at
org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
at
org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
at
org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:251)
at
org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:183)
at
org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:134)
at
org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
at
org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
at
org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:94)
at
org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
at
org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1650)
at
org.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:923)
at
org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
... 43 more
and if I put in the following:
<bean class="org.appfuse.dao.spring.HibernateExtensionPostProcessor">
<property name="annotatedClasses">
<list>
<value>org.appfuse.model.Person</value>
</list>
</property>
</bean>
everything just work fine. Could anyone kindly advice on this please? Thank
you!
Cheers,
Mark Thien
--
View this message in context:
http://n4.nabble.com/No-need-to-register-personDao-in-applicationContext-dao-xml-anymore-tp1744994p1744994.html
Sent from the AppFuse - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]