2011-05-02 66 views
0

我得到這個錯誤:Hibernate持久

GRAVE: Could not configure datastore from file

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> 

任何解決方案?

回答

0

該配置看起來不正確。您正在定義2個事務工廠(可能還有其他錯誤)。

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

我建議你到谷歌的配置文件的例子,並閱讀文檔。

+0

謝謝你,但它只是無法找到名爲「僱工」 – user726991 2011-05-02 16:09:03

+0

信息的實體類的唯一錯誤:hibernate.properties找不到 信息:從文件中配置:hibernate.cfg.xml中 信息:映射資源:組織/domain/projet/config/Employe.hbm.xml 信息:映射類:org.domain.projet.config.Employe - > employe INFO:配置的SessionFactory: 信息:映射文件:。\ Employe.hbm.xml GRAVE:無法從以下文件配置數據存儲:。\ Employe.hbm.xml java.io.FileNotFoundException:。\ Employe.hbm.xml(易於使用的插件) java.io.FileNotFoundException:。\ Employe.hbm。 xml(Le fichierspécifiéest introuvable) – user726991 2011-05-02 16:22:42

相關問題