日期:2014-05-18  浏览次数:20719 次

Hibernate 可编程配问题?100分

                        Configuration   cfg   =   new   Configuration()
                        .addFile( "CcCifNgtvInfo.hbm.xml ");
                        SessionFactory   sessions   =   cfg.buildSessionFactory();//到这里抛出异常
                        Session   sess   =   sessions.openSession(conn);//程序已有的连接

输出信息:
2007-9-7   17:06:00   org.hibernate.cfg.Environment
INFO:   Hibernate   3.2.5
2007-9-7   17:06:03   org.hibernate.cfg.Environment
INFO:   hibernate.properties   not   found
2007-9-7   17:06:03   org.hibernate.cfg.Environment
INFO:   Bytecode   provider   name   :   cglib
2007-9-7   17:06:04   org.hibernate.cfg.Environment
INFO:   using   JDK   1.4   java.sql.Timestamp   handling
2007-9-7   17:06:05   org.hibernate.cfg.Configuration
INFO:   Reading   mappings   from   file:   CcCifNgtvInfo.hbm.xml
2007-9-7   17:06:09   org.hibernate.cfg.HbmBinder
INFO:   Mapping   class:   core.cc.cif.entity.CcCifNgtvInfo   ->   CC_CIF_NGTV_INFO
2007-9-7   17:06:11   org.hibernate.mapping.RootClass
WARNING:   composite-id   class   does   not   override   equals():   core.cc.cif.entity.CcCifNgtvInfo
2007-9-7   17:06:11   org.hibernate.mapping.RootClass
WARNING:   composite-id   class   does   not   override   hashCode():   core.cc.cif.entity.CcCifNgtvInfo
2007-9-7   17:06:11   org.hibernate.connection.UserSuppliedConnectionProvider
WARNING:   No   connection   properties   specified   -   the   user   must   supply   JDBC   connections
Exception   in   thread   "main "   org.hibernate.HibernateException:   Hibernate   Dialect   must   be   explicitly   set
at   org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:57)
at   org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:39)
at   org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:426)
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   core.cc.cif.batch.HibernateTestJob.saveNgtvData(HibernateTestJob.java:129)
at   core.cc.cif.batch.HibernateTestJob.execute(HibernateTestJob.java:69)
at   core.cc.cif.batch.HibernateTestJob.main(HibernateTestJob.java:312)


------解决方案--------------------
Hibernate Dialect must be explicitly set
就是说你hibernate方言没设正确 检查你的hibernate.cfg.xml
<?xml version= "1.0 " encoding= "utf-8 "?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN "
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd ">

<hibernate-configuration>
<s