问题描述
我在Spring中并没有这么强大。
I am not so strong in Spring.
我有一个bean
I have a bean
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mappingResources">
<list>
<value>com/my/company/service/impl/entity/User.hbm.xml</value>
</list>
</property>
</bean>
User.hbm.xml引用了类( UserAddress )没有Hibernate映射类(像UserAddress.hbm.xml )。
The User.hbm.xml has references to class (UserAddress) that has not Hibernate mapping class (like UserAddress.hbm.xml). Instead of this the UserAddress has annotations in it class for mapping:
@Entity
@Table(name = "user_address")
public class UserAddress extends Base {
...
}
所以问题是:如何将添加到 sessionFactory bean?
So the question is: how can I add UserAddress to sessionFactory bean ?
推荐答案
好的,我找到了解决方案。而不是使用 org.springframework.orm.hibernate3.LocalSessionFactoryBean 它需要使用它: org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean
OK, I found the solution. Instead of using org.springframework.orm.hibernate3.LocalSessionFactoryBean it is needed to use it child: org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean
这篇关于带注释映射的LocalSessionFactoryBean的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!