Reputation: 3583
I'm having a weird problem using Spring and Hibernate. I started using Hibernate using this in hibernate.cfg.xml:
<property name="hbm2ddl.auto">create</property>
It worked fine, and Hibernate successfully created the tables needed in the database. Now I'm using Spring and my bean used for hibernate in applicationContext.xml looks like this:
<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 doesn't create them. I tried with create-drop
instead of create
(just in case someone asks). My DB Schema changed since I used Hibernate and I'm using a lot of getBeans("...");
in my code so it kind of bother me to reuse my Hibernate-only version just to create the tables. I also could create the table by hand, but what would be the point of using these frameworks?
I'm sure I'm doing something wrong somewhere, but I cannot find it. The console prompt an error saying there is no table named "the name of the table", so it connects to the DB successfully.
Thanks for your time :)
Upvotes: 4
Views: 3647
Reputation: 9697
There's a typo in your code
<prop key="hibernate.hbm2ddl.auto">create</prop>
in the solution
Upvotes: 1
Reputation: 691635
hibernate.hbm2dll.auto
--> hibernate.hbm2ddl.auto
DLL = Dynamic Link Library
DDL = Data Definition Language
Upvotes: 13