I have tried two approaches for creating the SessionFactory that the HibernateTemplate uses.
// loads the factory using Spring IoC from spring.xml
SessionFactory sessionFactory = (SessionFactory) factory.getBean("mySessionFactory");
OR
// loads the factory directly and reads values from hibernate.cfg.xml
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
I am using Spring 1.2 and Hibernate 3.0.3. When I instantiate the factory directly, the <hbm2ddl.auto>create</hbm2ddl.auto> works properly. However, when I load the factory via Spring IoC, the hibernateProperties do not seem to be loading properly (specifically the hbm2ddl.auto):
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.HSQL Dialect</prop>
<prop key="show_sql">true</prop>
<prop key="hbm2ddl.auto">create</prop>
</props>
</property>
Has anyone else run into this type of problem?


Reply With Quote