[code=java]
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="hibernate.connection.url" >jdbc:mysql://localhost:3306/reg</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.connection.password">root</property>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.hbm2ddl.auto">create</property>
        <property name="current_session_context_class">thread</property>
        <property name="show_sql">true</property>
        
        <mapping resource="entity/User.hbm.xml"/>
        <mapping resource="entity/Order.hbm.xml"/>
    </session-factory>
</hibernate-configuration>[/code]
上面是我的Hibernate.hbm.xml代码,在我启动项目的时候不能自动创建表。这是什么原因呢

解决方案 »

  1.   

    Hibernate.hbm.xml?这个配置文件是干嘛的..难道你有Hibernate表?
      

  2.   


    public class ExportUtil {
    public static void main(String[] args) {
    Configuration config = new Configuration();
    config.configure("hibernate.cfg.xml");
    SchemaExport export = new SchemaExport(config);
    export.create(true, true);
    }
    }是不是要这个~~~~
      

  3.   

    我只看到了连数据库的一些参数,没看出哪里是建表。不知道
    <mapping resource="entity/User.hbm.xml"/>         
    <mapping resource="entity/Order.hbm.xml"/>
    这两个映射文件有没有问题,还有是不是先建好了数据库。 
      

  4.   

       <property name="hibernate.hbm2ddl.auto">create</property>
      这里的参数还可以设置all,你试下呗
      

  5.   

    Hibernate.hbm.xml??文件名应该是hibernate.cfg.xml
    xxxx.hbm.xml 是实体映射的