hibernate 老说没有配方言
<property
name="dialect">org.hibernate.dialect.MySQLDialect</property> 这
句话明明就写在了配置文件里面,可老是没有写 错误如下: Exception in thread "main" org.hibernate.HibernateException:
Hibernate Dialect must be explicitly set
name
改成"hibernate.dialect"也不行
Hibernate-Version: 3.1.1 mysql -Verison:
4.0.16
用这种方法正确 static {
try { configuration = new
Configuration();
sessionFactory =
configuration.configure().buildSessionFactory(); } catch (Throwable
ex) {
throw new ExceptionInInitializerError(ex); } }
这
种方式会出现异常 // static { // try { // // Create a configuration
based on the properties file we've put // Configuration config = new
Configuration(); //
config.addClass(Customer.class).addClass(Order.class); // // Get the
session factory we can use for persistence // sessionFactory =
config.buildSessionFactory(); // } catch (Exception e) { //
e.printStackTrace(); // } // }
第二种方式是针对使用properties文件配置
hiernate的写法,使用hibernate.cfg.xml应使用第一种调用方式
或
者在hibernate.cfg.xml中加入:
<property name="current_session_context_class">thread</property>

|