小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

No CurrentSessionContext configured!" 異常解決方案 - esffor - JavaEye技術網(wǎng)站

 ShangShujie 2010-04-19

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);
}
}

這 種方式會出現(xiàn)異常
// 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>

    本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內容均由用戶發(fā)布,不代表本站觀點。請注意甄別內容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內容,請點擊一鍵舉報。
    轉藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多