0

hi i have a simple UserDetails class with @entity annotation and in my hibernate config file, the hbm2ddl is set to create but when running it shows the table UserDetails not exist. After I created the table it works fine. Why hibernate don't create table automatically even hbm2ddl is set to create? hibernate.cfg.xml

<hibernate-configuration>
<session-factory>

        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/shammu</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.connection.password">root</property>


        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>

        <property name="cache.provider_class">org.hibernate.cache.NocacheProvider</property>

        <property name="show_sql">true</property>

        <property name="hibernate.hbm2ddl">create</property>

        <mapping class="org.shammu.UserDetails" />

</session-factory>
</hibernate-configuration>
Shameer
  • 351
  • 2
  • 5
  • 11

2 Answers2

1

Update the below properties:

<property name="hibernate.hbm2ddl.auto">create</property>

Refer below for all the properties:

http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/session-configuration.html

ajay.patel
  • 1,957
  • 12
  • 15
0

You are using wrong property name. Make it

property name="hbm2ddl.auto"