[英]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.