Results 1 to 5 of 5

Thread: SessionFactory for Hibernate Issue (hbm2ddl.auto)

  1. #1
    Join Date
    May 2005
    Location
    New York, NY
    Posts
    6

    Default SessionFactory for Hibernate Issue (hbm2ddl.auto)

    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?

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    Try adding schemaUpdate to your LocalSessionFactoryBean. E.g.:
    Code:
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
       <property name="dataSource"><ref local="dataSource"/></property>
       <property name="configLocation"><value>classpath&#58;hibernate.cfg.xml</value></property>
       <property name="schemaUpdate"><value>true</value></property>
    </bean>

  3. #3
    Join Date
    May 2005
    Location
    New York, NY
    Posts
    6

    Default

    Actually I found out the problem was this:

    <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>

    i was missing the "hibernate." prefix. Notice the difference between the "hibernate.dialect" and the "hbm2ddl.auto".

    <prop key="hibernate.hbm2ddl.auto">create</prop> is the solution

  4. #4

    Question

    This shouldn't matter in my opinion. I use and forget hibernate prefix all the time ... ( it works both ways )

    thats weird

    Regards
    Vyas, Anirudh
    Regards
    Vyas, Anirudh

  5. #5
    Join Date
    Apr 2008
    Posts
    1

    Default

    I'd like to re-iterate the solution here. You need a hibernate. in front of that particular parameter for it to work. I searched the whole web looking for why my tables weren't being generated. Thanks OP.

Similar Threads

  1. Context initialization failed
    By kanonmicke in forum Container
    Replies: 7
    Last Post: Sep 29th, 2005, 12:35 AM
  2. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  3. Replies: 1
    Last Post: Jul 17th, 2005, 04:56 AM
  4. Replies: 2
    Last Post: Jun 2nd, 2005, 05:35 PM
  5. Replies: 1
    Last Post: Dec 17th, 2004, 06:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •