We're having an interesting issue with Spring + Hibernate + Maven in AppFuse 2.x (Maven 2.0.4, Hibernate 3.2.1 and Spring 2.0.1).
We have a "hibernate" module that contains the following bean definition for its sessionFactory bean.
This sessionFactory is defined in an applicationContext-dao.xml that's packaged in the root of the JAR. It's then loaded with the following in web.xml:Code:<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="configLocation" value="classpath:hibernate.cfg.xml"/> <property name="hibernateProperties"> <value> hibernate.dialect=${hibernate.dialect} hibernate.hbm2ddl.auto=update hibernate.query.substitutions=true 'Y', false 'N' </value> </property> </bean>
For some reason, the sessionFactory can't seem to read the hibernate.cfg.xml in the local project. I get an "Unknown Entity" exception. Using a PostProcessor works (see below), but the hibernate3-maven-plugin requires annotated classes be configured in hibernate.cfg.xml. It does support a <scan-jars/> configuration, but it takes twices as long as using hibernate.cfg.xml.Code:<context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath*:/applicationContext-resources.xml classpath*:/applicationContext-dao.xml classpath*:/applicationContext-service.xml /WEB-INF/applicationContext*.xml /WEB-INF/security.xml </param-value> </context-param>
Changing to use classpath*:hibernate.cfg.xml doesn't seem to help. Re-defining the sessionFactory bean in a local context file doesn't work. Registering the class with hibernate.cfg.xml and a PostProcessor is our current solution.Code:<bean class="org.appfuse.dao.spring.HibernateExtensionPostProcessor"> <property name="annotatedClasses"> <list> <value>org.appfuse.tutorial.model.Person</value> </list> </property> </bean>
Any ideas?
Another issue I'm experiencing is HQL seems to require the fully-qualified class name.
http://issues.appfuse.org/browse/APF-571
Thanks,
Matt


Reply With Quote