【发布时间】:2012-12-17 07:55:40
【问题描述】:
我有这个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();
这就是我得到的
最后一个原因:元素类型“session-factory”的内容必须匹配“(property*,mapping*,(class-cache|collection-cache),event,listener*)”。
这是为什么呢?怎么了?
【问题讨论】:
-
你能发布完整的hibernate.cfg.xml源码吗?
-
标签中的空格只是复制/粘贴错误?
标签: hibernate