Why is Hibernate throwing a SQLGrammarException saying table/view does not exist when I've set hbm2ddl.auto to create?

放肆的年华 提交于 2019-12-04 13:12:58

The property names should be prefixed with hibernate.

<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="packagesToScan" value="org.springpractice.domain" />
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">
                org.hibernate.dialect.DerbyTenSevenDialect</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.cache.provider_class">
                org.hibernate.cache.NoCacheProvider</prop>
            <prop key="hibernate.hbm2ddl.auto">create</prop>
        </props>
    </property> 
</bean>

BTW there is a simpler way to configure properties as follows

    <property name="hibernateProperties">
        <value>
            hibernate.dialect=org.hibernate.dialect.DerbyTenSevenDialect
            hibernate.show_sql=true
            hibernate.cache.provider_class=org.hibernate.cache.NoCacheProvider
            hibernate.hbm2ddl.auto"=create
        </value>
    </property> 
Ahamed Mustafa M
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!