I'm trying to combine Spring with Hibernate using Annotations and I'm getting the following error:
org.springframework.orm.hibernate3.HibernateSystemException : Unknown entity: entities.Bar; nested exception is org.hibernate.MappingException: Unknown entity: entities.Bar
Here is my setup...
My Entity:
package entities;
@Entity
public class Bar implements Serializable
{
...
}
My Bean:
package blah;
@Repository
@Service("fooService")
@RemotingDestination(channels = { "my-amf" })
public class Foo
{
protected HibernateTemplate template;
@Autowired
public void setSessionFactory(SessionFactory sessionFactory)
{
template = new HibernateTemplate(sessionFactory);
}
@RemotingInclude
public void addBar(String name) throws DataAccessException
{
Bar bar = new Bar();
bar.setName(name);
template.save(bar);
}
}
I'm enabling annotations in Spring:
<context:annotation-config />
<context:component-scan base-package="blah" />
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.h2.Driver" />
<property name="url" value="jdbc:h2:~/blahdb/blahdb" />
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses">
<list>
<value>entities.Bar</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.H2Dialect</prop>
<prop key="hibernate.hbm2ddl.auto">create</prop>
</props>
</property>
</bean>
I get the error when I call my Foo.addBar method from a Flex application through BlazeDS.
I'd really like to avoid additional configuration and it seems this should all work.
I'm using Spring 3.0.0.RC1, Hibernate Annotations 3.4.0, Tomcat 6.0.20, and Java 1.6.0_15.
Any ideas? Thanks.