2013-07-29 76 views
0

我有这个配置问题:Spring-JPA-Hibernate配置:设置属性hiberate.hbm2dll.auto创建没有效果?

1)我有jpaPropertyMap属性hibernate.hbm2dll.auto设置为创建,但它没有效果。它不创建表生成SQL。

我可以在日志文件中看到其他jpaPropertyMap属性,如方言得到正确设置,因此正在读取属性图。

2)如果我将HibernateJpaVendorAdapter属性generateddl设置为true,则表格正在生成。

为什么hibernate.hbm2dll.auto不能在case/generate表中工作。

下面是配置文件:

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:tx="http://www.springframework.org/schema/tx" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans-3.2.xsd 
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd 
     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd"> 

    <context:annotation-config /> 
    <context:component-scan base-package="org.demoapps.placementwebsite"/> 

    <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" /> 

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> 
     <property name="driverClassName" value="com.mysql.jdbc.Driver"/> 
     <property name="url" value="jdbc:mysql://localhost:3306/cpm?autoReconnect=true" /> 
     <property name="username" value="user" /> 
     <property name="password" value="password" /> 
    </bean> 

    <bean id="entityManagerFactory" 
     class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> 
     <property name="persistenceUnitName" value="punit" /> 
     <property name="dataSource" ref="dataSource" /> 
     <property name="jpaVendorAdapter"> 
      <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> 
       <property name="showSql" value="true" /> 
      </bean> 
     </property> 

     <property name="jpaPropertyMap"> 
      <map> 
       <entry key="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" /> 
       <entry key="hibernate.hbm2dll.auto" value="create"/> 
       <entry key="hibernate.format_sql" value="true" /> 
      </map> 
     </property> 
    </bean> 

    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> 
     <property name="entityManagerFactory" ref="entityManagerFactory" /> 
    </bean> 

    <tx:annotation-driven transaction-manager="transactionManager" /> 
</beans> 

使用: 休眠4.2.2.Final 春3.2.3.RELEASE

回答

5

该物业是hibernate.hbm2ddl.auto,而不是hibernate.hbm2dll.auto

DDL =数据定义语言

DLL =动态链接库