休眠 4 不创建表



我正在使用MySQL5和我的applicationContext.xml具有以下bean:

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
    destroy-method="close">
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <property name="url" value="jdbc:mysql://localhost:3306/ems" />
    <property name="username" value="root" />
    <property name="password" value="admin" />
</bean>
<bean id="sessionFactory"
    class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hbm2ddl.auto">create</prop>
            <prop key="connection.url">jdbc:mysql://localhost:3306/ems</prop>
            <prop key="connection.username">root</prop>
            <prop key="connection.password">admin</prop>
            <prop key="connection.driver_class">com.mysql.jdbc.Driver</prop>
        </props>
    </property>
    <property name="mappingDirectoryLocations" value="/WEB-INF/resources/mappings" />
</bean>

我已经使用 MySQL 工作台创建了一个名为"ems"的模式,但是当我在控制台中部署应用程序时,它会打印:

01:22:54,823 INFO  [org.hibernate.cfg.Environment] (MSC service thread 1-2) HHH000206: hibernate.properties not found
01:22:54,827 INFO  [org.hibernate.cfg.Environment] (MSC service thread 1-2) HHH000021: Bytecode provider name : javassist
01:22:54,841 INFO  [org.hibernate.cfg.Configuration] (MSC service thread 1-2) HHH000220: Reading mappings from file: C:DevelopmentJBoss-AS-7.1.0.Finalstandalonetmpvfstempf3cbb10675b49730EMSApplication.war-43fc183fcacfc03fWEB-INFresourcesmappingsUser.hbm.xml
01:22:56,884 INFO  [org.hibernate.dialect.Dialect] (MSC service thread 1-2) HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
01:22:56,892 INFO  [org.hibernate.engine.jdbc.internal.LobCreatorBuilder] (MSC service thread 1-2) HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
01:22:56,901 INFO  [org.hibernate.engine.transaction.internal.TransactionFactoryInitiator] (MSC service thread 1-2) HHH000399: Using default transaction strategy (direct JDBC transactions)
01:22:56,908 INFO  [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (MSC service thread 1-2) HHH000397: Using ASTQueryTranslatorFactory

控制台中没有例外。但在架构 ems 中,表是空的,这意味着尚未创建任何表。

User.hbm.xml 驻留在指定位置,该位置为:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC 
  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  "http://www.jboss.org/dtd/hibernate/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
    <class name="app.dev.ems.data.model.User" table="USER">
        <id name="id" column="ID">
            <generator class="native"/>         
        </id>
    </class>
</hibernate-mapping>

用户.java也存在。

我正在使用休眠核心-4.1.1.Final 与 spring-orm-3.1.1.RELEASE。

我做错了什么?

我犯了一个错误:<prop key="hbm2ddl.auto">create</prop><prop key="hibernate.hbm2ddl.auto">create</prop>

相关内容

  • 没有找到相关文章

最新更新