Java 第一次休眠测试出现错误[已编辑]

Java 第一次休眠测试出现错误[已编辑],java,android,spring,hibernate,Java,Android,Spring,Hibernate,我是一个Hibernate初学者,我创建了一个非常简单的应用程序来测试它! 但我在控制台中发现了这个错误: Initial SessionFactory creation failed.org.hibernate.HibernateException: Dialect class not found: org.openmeetings.app.hibernate.utils.MySQL5MyISAMDialect Exception in thread "main" java.lang.

我是一个Hibernate初学者,我创建了一个非常简单的应用程序来测试它! 但我在控制台中发现了这个错误:

    Initial SessionFactory creation failed.org.hibernate.HibernateException: Dialect class not found: org.openmeetings.app.hibernate.utils.MySQL5MyISAMDialect
Exception in thread "main" java.lang.ExceptionInInitializerError
   at util.HibernateUtil.buildSessionFactory(HibernateUtil.java:20)
   at util.HibernateUtil.<clinit>(HibernateUtil.java:10)
   at DAO.services.addProduit(services.java:9)
   at test.main(test.java:11)
Caused by: org.hibernate.HibernateException: Dialect class not found: org.openmeetings.app.hibernate.utils.MySQL5MyISAMDialect
   at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:81)
   at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:42)
   at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:422)
   at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:128)
   at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
   at util.HibernateUtil.buildSessionFactory(HibernateUtil.java:15)
   ... 3 more
Hibernate.cfg.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<!-- Generated file - Do not edit! -->

<hibernate-configuration>

        <!-- a SessionFactory instance listed as /jndi/name -->
        <session-factory>

                <!-- User  / Password -->
                <property name="connection.username">root</property>
                <property name="connection.password"></property>

                <!-- Database Settings -->
                <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
                <!--  for performance reasons changed to MyISAM from org.hibernate.dialect.MySQLInnoDBDialect -->
                <property name="dialect">org.openmeetings.app.hibernate.utils.MySQL5MyISAMDialect</property>
                <property name="connection.url">jdbc:mysql://localhost:3306/gestProd</property>     

                <property name="hibernate.connection.CharSet">utf8</property>
                <property name="hibernate.connection.characterEncoding">utf8</property>
                <property name="hibernate.connection.useUnicode">true</property>


                <!-- Database Scheme Auto Update -->
                <property name="hbm2ddl.auto">update</property>                 

                <!-- properties -->

                <property name="show_sql">true</property>
                <property name="use_outer_join">false</property>
                <property name="hibernate.query.factory_class">org.hibernate.hql.ast.ASTQueryTranslatorFactory</property>
        <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
        <!--
        <property name="connection.provider_class ">org.hibernate.connection.C3P0ConnectionProvider</property>
         -->
        <property name="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
        <property name="hibernate.cache.use_query_cache">false</property>
        <property name="hibernate.cache.use_second_level_cache">false</property>
        <property name="hibernate.generate_statistics">false</property>
        <property name="hibernate.cache.use_structured_entries">false</property>


        <property name="hibernate.c3p0.max_size">20</property>
        <property name="hibernate.c3p0.min_size">2</property>
        <property name="hibernate.c3p0.idle_test_period">100</property>
        <property name="hibernate.c3p0.max_statements">100</property>
        <property name="hibernate.c3p0.timeout">100</property>

                <!-- mapping files -->
        <mapping resource="DAO/Categorie.hbm.xml"/>
        <mapping resource="DAO/Produit.hbm.xml"/>        


        </session-factory>

</hibernate-configuration>
最后是我的对象的两个类(Produit和Categorie)及其配置文件

你认为这一错误的根源是什么


谢谢:)

MySql和MyISAM的方言(如果你有的话)应该是:

org.hibernate.dial.MySQLMyISAMDialect


MyISAM的MySql方言(如果您有)应该是:

org.hibernate.dial.MySQLMyISAMDialect


欢迎来到堆栈溢出。也请考虑发布你怀疑给你这个错误的代码的一部分。谢谢@ OlivierDeMeulder!我添加了一些文件!等待您的帮助;)欢迎来到堆栈溢出。也请考虑发布你怀疑给你这个错误的代码的一部分。谢谢@ OlivierDeMeulder!我添加了一些文件!等待您的帮助;)很高兴我能帮上忙:)很高兴我能帮上忙:)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<!-- Generated file - Do not edit! -->

<hibernate-configuration>

        <!-- a SessionFactory instance listed as /jndi/name -->
        <session-factory>

                <!-- User  / Password -->
                <property name="connection.username">root</property>
                <property name="connection.password"></property>

                <!-- Database Settings -->
                <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
                <!--  for performance reasons changed to MyISAM from org.hibernate.dialect.MySQLInnoDBDialect -->
                <property name="dialect">org.openmeetings.app.hibernate.utils.MySQL5MyISAMDialect</property>
                <property name="connection.url">jdbc:mysql://localhost:3306/gestProd</property>     

                <property name="hibernate.connection.CharSet">utf8</property>
                <property name="hibernate.connection.characterEncoding">utf8</property>
                <property name="hibernate.connection.useUnicode">true</property>


                <!-- Database Scheme Auto Update -->
                <property name="hbm2ddl.auto">update</property>                 

                <!-- properties -->

                <property name="show_sql">true</property>
                <property name="use_outer_join">false</property>
                <property name="hibernate.query.factory_class">org.hibernate.hql.ast.ASTQueryTranslatorFactory</property>
        <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
        <!--
        <property name="connection.provider_class ">org.hibernate.connection.C3P0ConnectionProvider</property>
         -->
        <property name="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
        <property name="hibernate.cache.use_query_cache">false</property>
        <property name="hibernate.cache.use_second_level_cache">false</property>
        <property name="hibernate.generate_statistics">false</property>
        <property name="hibernate.cache.use_structured_entries">false</property>


        <property name="hibernate.c3p0.max_size">20</property>
        <property name="hibernate.c3p0.min_size">2</property>
        <property name="hibernate.c3p0.idle_test_period">100</property>
        <property name="hibernate.c3p0.max_statements">100</property>
        <property name="hibernate.c3p0.timeout">100</property>

                <!-- mapping files -->
        <mapping resource="DAO/Categorie.hbm.xml"/>
        <mapping resource="DAO/Produit.hbm.xml"/>        


        </session-factory>

</hibernate-configuration>
package DAO;

import org.hibernate.Session;
import util.HibernateUtil;
public class services {

    public void addProduit(Produit p){

        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
        session.save(p);
        session.getTransaction().commit();

    }

}