繁体   English   中英

会话工厂的休眠错误

[英]Hibernate error with session factory

我有这个hibernate.cfg.xml

 <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE hibernate-configuration PUBLIC
              "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
              "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>

      <session-factory>

        <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
        <mapping class="iger.User"/>
        <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="connection.url">jdbc:mysql://localhost/MyAppBase</property>
        <property name="connection.username">root</property>
        <property name="connection.password">root</property>


        <property name="hibernate.hbm2ddl.auto"> create </property>
        <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
        <property name="current_session_context_class">thread</property>
        <property name="hibernate.show_sql">true</property>
      </session-factory>

< /hibernate-configuration>

这是我尝试创建会话的地方

SessionFactory factory= new Configuration().configure("iger/hibernate.cfg.xml").buildSessionFactory();
                Session session = factory.openSession();

                session.beginTransaction();
                session.save(regUser);
                session.getTransaction().commit();

这就是我所得到的

上一个原因:元素类型“会话工厂”的内容必须与“((属性*,映射*,(类缓存|集合缓存) ,事件 ,侦听器*)”)匹配。

这是为什么? 怎么了?

请发布您完整的hibernate.cfg.xml :这可能是您映射中的问题,请查看此链接

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM