国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項超值服

開通VIP
hibernate官方文檔(介紹hbm.xml配置的)
http://www.hibernate.org/114.html

If you use Hibernate on Tomcat you don't have to use Tomcat'sJNDI-bound JDBC connections. You can let Hibernate manage the JDBCconnection pool. This works on all versions of Tomcat and is very easyto configure.

First, create a hibernate.cfg.xml or hibernate.propertiesfile, as per documentation (no, property names in cfg.xml don't have tobe prefixed with "hibernate.xxx"):

<!DOCTYPE hibernate-configuration PUBLIC 
    "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"
>

<hibernate-configuration>
    
<session-factory>
    
        
<!-- Settings for a local HSQL (testing) database. -->
        
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>
        
<property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
        
<property name="connection.url">jdbc:hsqldb:hsql://localhost</property>
        
<property name="connection.username">sa</property>
        
<property name="connection.password"></property>

        
<!-- Use the C3P0 connection pool. -->
        
<property name="c3p0.min_size">3</property>
        
<property name="c3p0.max_size">5</property>
        
<property name="c3p0.timeout">1800</property>
    
        
<!-- Disable second-level cache. -->
        
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
        
<property name="cache.use_query_cache">false</property>
        
<property name="cache.use_minimal_puts">false</property>
        
<property name="max_fetch_depth">3</property>
    
        
<!-- Print SQL to stdout. -->
        
<property name="show_sql">true</property>
        
<property name="format_sql">true</property>
    
        
<!-- Drop and then re-create schema on SessionFactory build, for testing. -->
        
<property name="hbm2ddl.auto">create</property>
    
        
<!-- Bind the getCurrentSession() method to the thread. -->
        
<property name="current_session_context_class">thread</property>

        
<!-- Hibernate XML mapping files -->
        
<mapping resource="org/MyClass.hbm.xml"/>
    
        
<!-- Hibernate Annotations (and package-info.java)
        <mapping package="org.mypackage"/>
        <mapping class="org.MyClass/>
        
-->

    
</session-factory>

</hibernate-configuration>

Now copy this file into your WEB-INF/classes directory ofyour web application. Copy hibernate3.jar into your WEB-INF/libdirectory and with it all required 3rd party libraries (seelib/README.txt in the Hibernate distribution). Don't forget to also copyyour JDBC driver to common/lib or WEB-INF/lib. Neverever copy anything in Tomcat into a global directory outside of yourweb application or you are in classloader hell!

Start Hibernate by building a SessionFactory, as shown here with HibernateUtil.

This listener initializes and closes Hibernate on deployment andundeployment, instead of the first user request hitting the application:

public class HibernateListener implements ServletContextListener {

    
public void contextInitialized(ServletContextEvent event) {
        HibernateUtil.getSessionFactory(); 
// Just call the static initializer of that class    
    }


    
public void contextDestroyed(ServletContextEvent event) {
        HibernateUtil.getSessionFactory().close(); 
// Free all resources
    }

}
Add it to your web.xml:

<listener>
    
<listener-class>org.mypackage.HibernateListener</listener-class>
</listener>
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Hibernate入門教程(純Eclipse版)
hibernate官方入門教程 (轉(zhuǎn)載)
CSDN 文檔中心:Hibernate訪問多個數(shù)據(jù)庫
ANT+Xdoclet自動生成Hibernate配置文件\映射文件(正確)
SSH整合開發(fā)環(huán)境搭建的一種解決方案
一對一主鍵關(guān)聯(lián)映射(單向)
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服