简体   繁体   中英

Hibernate error with session factory

I have got this 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>

this is where i try to create a session

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

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

and this i what i get

Last cause: The content of element type "session-factory" must match "(property*,mapping*,(class-cache|collection-cache) ,event ,listener*)".

Why is that? What's wrong?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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