I am having a weird problem using Spring and Hibernate. I started using Hibernate using this in the hibernate.cfg.xml file:
<property name="hbm2ddl.auto">create</property>
It worked perfectly, and Hibernate successfully created the tables needed in the database. Now I am using Spring, and my bean used for sleep mode in applicationContext.xml is as follows:
<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="myDataSource" /> <property name="mappingResources"> <list> <value>domain/Entity.hbm.xml</value> <value>domain/Service.hbm.xml</value> <value>domain/User.hbm.xml</value> <value>domain/Arcos.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="hibernate.hbm2dll.auto">create</prop> </props> </property> </bean>
I had to drop the tables created by Hibernate at some point, but Spring does not create them. I tried to use create-drop instead of create (just in case someone asks). My database schema has changed since I used Hibernate, and I use a lot of getBeans("..."); in my code getBeans("..."); , so it somehow interferes with me reusing only the version of Hibernate to create tables. I could also create the table manually, but what's the point of using these frameworks?
I am sure that I am doing something wrong, but I can not find it. A message appears on the command line stating that there is no table named "table name", so it successfully connects to the database.
Thank you for your time:)
source share