休眠持久性

时间:2011-05-02 15:23:25

标签: hibernate

我收到此错误:

  

GRAVE:无法从文件

配置数据存储区

hibernate.cgf.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 name="">
  <property name="hibernate.connection.driver_class">com.jdbc.mysql.driver</property>
  <property name="hibernate.connection.password">manel</property>
  <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/pfe</property>
  <property name="hibernate.connection.username">root</property>
  <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
  <!-- JDBC connection pool (use the built-in) -->
  <property name="connection.pool_size">1</property>
  <!-- Enable Hibernate's automatic session context management -->
  <property name="current_session_context_class">thread</property>
  <!-- Disable the second-level cache  -->
  <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
  <property name="hibernate.hbm2ddl.auto">update</property>
  <!-- Echo all executed SQL to stdout -->
  <property name="show_sql">true</property>
  <!-- Drop and re-create the database schema on startup -->
  <property name="hbm2ddl.auto">update</property>
  <property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
  <property name="jta.UserTransaction">java:comp/UserTransaction</property>
  <property name="hibernate.transaction.factory_class">net.sf.hibernate.transaction.JDBCTransactionFactory</property>
  <mapping resource="org/domain/projet/config/Employe.hbm.xml"/>
  <mapping class="org.domain.projet.config.Employe" file="Employe" package="org.domain.projet.config"/>
  <event type="save-update"/>
 </session-factory>
</hibernate-configuration>

Employe.hbm.xml:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping package="org.domain.projet.config">
    <class name="Employe" table="employe" lazy="false">
        <id
            column="id"
            name="Id"
            type="integer"
        >
            <generator class="vm" />
        </id>
        <property
            column="prenom"
            length="45"
            name="Prenom"
            not-null="true"
            type="string"
         />
        <property
            column="mail"
            length="45"
            name="Mail"
            not-null="true"
            type="string"
         />
        <property
            column="adresse"
            length="45"
            name="Adresse"
            not-null="true"
            type="string"
         />
        <property
            column="tel"
            length="10"
            name="Tel"
            not-null="true"
            type="integer"
         />
        <property
            column="service"
            length="45"
            name="Service"
            not-null="true"
            type="string"
         />
        <property
            column="fonction"
            length="45"
            name="Fonction"
            not-null="true"
            type="string"
         />
        <property
            column="login"
            length="45"
            name="Login"
            not-null="true"
            type="string"
         />
        <property
            column="password"
            length="45"
            name="Password"
            not-null="true"
            type="string"
         />
        <property
            column="matricule"
            length="45"
            name="Matricule"
            not-null="true"
            type="string"
         />
        <property
            column="nom"
            length="45"
            name="Nom"
            not-null="true"
            type="string"
         />
    </class>
</hibernate-mapping>

任何解决方案?

1 个答案:

答案 0 :(得分:0)

配置看起来不正确。您正在定义2个事务工厂(可能还有其他错误)。

<property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="hibernate.transaction.factory_class">net.sf.hibernate.transaction.JDBCTransactionFactory</property>

我建议您使用谷歌搜索配置文件的示例并阅读文档。