java - first Hibernate test gives error [EDITED] -
i'm hibernate beginner user, created simple application test ! error in console :
initial sessionfactory creation failed.org.hibernate.hibernateexception: dialect class not found: org.openmeetings.app.hibernate.utils.mysql5myisamdialect exception in thread "main" java.lang.exceptionininitializererror @ util.hibernateutil.buildsessionfactory(hibernateutil.java:20) @ util.hibernateutil.<clinit>(hibernateutil.java:10) @ dao.services.addproduit(services.java:9) @ test.main(test.java:11) caused by: org.hibernate.hibernateexception: dialect class not found: org.openmeetings.app.hibernate.utils.mysql5myisamdialect @ org.hibernate.dialect.dialectfactory.builddialect(dialectfactory.java:81) @ org.hibernate.dialect.dialectfactory.builddialect(dialectfactory.java:42) @ org.hibernate.cfg.settingsfactory.determinedialect(settingsfactory.java:422) @ org.hibernate.cfg.settingsfactory.buildsettings(settingsfactory.java:128) @ org.hibernate.cfg.configuration.buildsettings(configuration.java:2009) @ org.hibernate.cfg.configuration.buildsessionfactory(configuration.java:1292) @ util.hibernateutil.buildsessionfactory(hibernateutil.java:15) ... 3 more
my test class :
import dao.services; import dao.produit; public class test { public static void main(string[] args) { // todo auto-generated method stub services s = new services(); produit p = new produit("pc","sony vaio",(double )7500); s.addproduit(p); } }
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 - not edit! --> <hibernate-configuration> <!-- sessionfactory instance listed /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> <!-- performance reasons changed myisam 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>
service.java :
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(); } }
and 2 classes objects ( produit , categorie ) , configuration files !
what think may source of error ?
thank :)
the dialect mysql myisam(if have) should be:
org.hibernate.dialect.mysqlmyisamdialect
Comments
Post a Comment