Hello, everyone:
I meet a problem, I have an entity called User, which annotated by java persistence api,
<bean id="_sessionFactory" class="org.springdmhibernate.bean.MySessionFactoryBean">
<property name="dataSource" ref="_dataSource"/>
<property name="annotatedClasses">
<list>
<value>org.test.model.User</value>
</list>
</property>
</bean>
MySessionFactoryBean is :
public class MySessionFactoryBean extends AnnotationSessionFactoryBean
it can run successfully, and the db generated the table t_user, it's normal.
But now, I don't want to config the annotatedClasses to map entities, I want to do it in code, so I do bellow:
I override the method in MySessionFactoryBean:
@Override
protected void postProcessMappings(Configuration config)
throws HibernateException {
config.addClass(User.class); // <-----stopping here
super.postProcessMappings(config);
}
But when run again , the programe stopping at config.addClass(User.class), and don't throw exceptions.
So, I am very confused, Because I use OSGi in my Application, must map my entites dynamiclly.
Help me, Please mail to
[email protected] , thank you !!