亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? hibernatetemplate.java

?? spring framework 2.5.4源代碼
?? JAVA
?? 第 1 頁(yè) / 共 4 頁(yè)
字號(hào):
/*
 * Copyright 2002-2008 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.orm.hibernate3;

import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.sql.SQLException;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Filter;
import org.hibernate.FlushMode;
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.ReplicationMode;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Example;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.event.EventSource;

import org.springframework.dao.DataAccessException;
import org.springframework.dao.DataAccessResourceFailureException;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.util.Assert;

/**
 * Helper class that simplifies Hibernate data access code. Automatically
 * converts HibernateExceptions into DataAccessExceptions, following the
 * <code>org.springframework.dao</code> exception hierarchy.
 *
 * <p>The central method is <code>execute</code>, supporting Hibernate access code
 * implementing the {@link HibernateCallback} interface. It provides Hibernate Session
 * handling such that neither the HibernateCallback implementation nor the calling
 * code needs to explicitly care about retrieving/closing Hibernate Sessions,
 * or handling Session lifecycle exceptions. For typical single step actions,
 * there are various convenience methods (find, load, saveOrUpdate, delete).
 *
 * <p>Can be used within a service implementation via direct instantiation
 * with a SessionFactory reference, or get prepared in an application context
 * and given to services as bean reference. Note: The SessionFactory should
 * always be configured as bean in the application context, in the first case
 * given to the service directly, in the second case to the prepared template.
 *
 * <p><b>NOTE: As of Hibernate 3.0.1, transactional Hibernate access code can
 * also be coded in plain Hibernate style. Hence, for newly started projects,
 * consider adopting the standard Hibernate3 style of coding data access objects
 * instead, based on {@link org.hibernate.SessionFactory#getCurrentSession()}.</b>
 *
 * <p>This class can be considered as direct alternative to working with the raw
 * Hibernate3 Session API (through <code>SessionFactory.getCurrentSession()</code>).
 * The major advantage is its automatic conversion to DataAccessExceptions as well
 * as its capability to fall back to 'auto-commit' style behavior when used outside
 * of transactions. <b>Note that HibernateTemplate will perform its own Session
 * management, not participating in a custom Hibernate CurrentSessionContext
 * unless you explicitly switch {@link #setAllowCreate "allowCreate"} to "false".</b>
 *
 * <p>{@link LocalSessionFactoryBean} is the preferred way of obtaining a reference
 * to a specific Hibernate SessionFactory, at least in a non-EJB environment.
 * The Spring application context will manage its lifecycle, initializing and
 * shutting down the factory as part of the application.
 *
 * <p>Note that operations that return an Iterator (i.e. <code>iterate</code>)
 * are supposed to be used within Spring-driven or JTA-driven transactions
 * (with HibernateTransactionManager, JtaTransactionManager, or EJB CMT).
 * Else, the Iterator won't be able to read results from its ResultSet anymore,
 * as the underlying Hibernate Session will already have been closed.
 *
 * <p>Lazy loading will also just work with an open Hibernate Session,
 * either within a transaction or within OpenSessionInViewFilter/Interceptor.
 * Furthermore, some operations just make sense within transactions,
 * for example: <code>contains</code>, <code>evict</code>, <code>lock</code>,
 * <code>flush</code>, <code>clear</code>.
 *
 * @author Juergen Hoeller
 * @since 1.2
 * @see #setSessionFactory
 * @see HibernateCallback
 * @see org.hibernate.Session
 * @see LocalSessionFactoryBean
 * @see HibernateTransactionManager
 * @see org.springframework.transaction.jta.JtaTransactionManager
 * @see org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
 * @see org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor
 */
public class HibernateTemplate extends HibernateAccessor implements HibernateOperations {

	private boolean allowCreate = true;

	private boolean alwaysUseNewSession = false;

	private boolean exposeNativeSession = false;

	private boolean checkWriteOperations = true;

	private boolean cacheQueries = false;

	private String queryCacheRegion;

	private int fetchSize = 0;

	private int maxResults = 0;


	/**
	 * Create a new HibernateTemplate instance.
	 */
	public HibernateTemplate() {
	}

	/**
	 * Create a new HibernateTemplate instance.
	 * @param sessionFactory SessionFactory to create Sessions
	 */
	public HibernateTemplate(SessionFactory sessionFactory) {
		setSessionFactory(sessionFactory);
		afterPropertiesSet();
	}

	/**
	 * Create a new HibernateTemplate instance.
	 * @param sessionFactory SessionFactory to create Sessions
	 * @param allowCreate if a non-transactional Session should be created when no
	 * transactional Session can be found for the current thread
	 */
	public HibernateTemplate(SessionFactory sessionFactory, boolean allowCreate) {
		setSessionFactory(sessionFactory);
		setAllowCreate(allowCreate);
		afterPropertiesSet();
	}


	/**
	 * Set if a new {@link Session} should be created when no transactional
	 * <code>Session</code> can be found for the current thread.
	 * The default value is <code>true</code>.
	 * <p><code>HibernateTemplate</code> is aware of a corresponding
	 * <code>Session</code> bound to the current thread, for example when using
	 * {@link HibernateTransactionManager}. If <code>allowCreate</code> is
	 * <code>true</code>, a new non-transactional <code>Session</code> will be
	 * created if none is found, which needs to be closed at the end of the operation.
	 * If <code>false</code>, an {@link IllegalStateException} will get thrown in
	 * this case.
	 * <p><b>NOTE: As of Spring 2.5, switching <code>allowCreate</code>
	 * to <code>false</code> will delegate to Hibernate's
	 * {@link org.hibernate.SessionFactory#getCurrentSession()} method,</b>
	 * which - with Spring-based setup - will by default delegate to Spring's
	 * <code>SessionFactoryUtils.getSession(sessionFactory, false)</code>.
	 * This mode also allows for custom Hibernate CurrentSessionContext strategies
	 * to be plugged in, whereas <code>allowCreate</code> set to <code>true</code>
	 * will always use a Spring-managed Hibernate Session.
	 * @see SessionFactoryUtils#getSession(SessionFactory, boolean)
	 */
	public void setAllowCreate(boolean allowCreate) {
		this.allowCreate = allowCreate;
	}

	/**
	 * Return if a new Session should be created if no thread-bound found.
	 */
	public boolean isAllowCreate() {
		return this.allowCreate;
	}

	/**
	 * Set whether to always use a new Hibernate Session for this template.
	 * Default is "false"; if activated, all operations on this template will
	 * work on a new Hibernate Session even in case of a pre-bound Session
	 * (for example, within a transaction or OpenSessionInViewFilter).
	 * <p>Within a transaction, a new Hibernate Session used by this template
	 * will participate in the transaction through using the same JDBC
	 * Connection. In such a scenario, multiple Sessions will participate
	 * in the same database transaction.
	 * <p>Turn this on for operations that are supposed to always execute
	 * independently, without side effects caused by a shared Hibernate Session.
	 */
	public void setAlwaysUseNewSession(boolean alwaysUseNewSession) {
		this.alwaysUseNewSession = alwaysUseNewSession;
	}

	/**
	 * Return whether to always use a new Hibernate Session for this template.
	 */
	public boolean isAlwaysUseNewSession() {
		return this.alwaysUseNewSession;
	}

	/**
	 * Set whether to expose the native Hibernate Session to
	 * HibernateCallback code.
	 * <p>Default is "false": a Session proxy will be returned, suppressing
	 * <code>close</code> calls and automatically applying query cache
	 * settings and transaction timeouts.
	 * @see HibernateCallback
	 * @see org.hibernate.Session
	 * @see #setCacheQueries
	 * @see #setQueryCacheRegion
	 * @see #prepareQuery
	 * @see #prepareCriteria
	 */
	public void setExposeNativeSession(boolean exposeNativeSession) {
		this.exposeNativeSession = exposeNativeSession;
	}

	/**
	 * Return whether to expose the native Hibernate Session to
	 * HibernateCallback code, or rather a Session proxy.
	 */
	public boolean isExposeNativeSession() {
		return this.exposeNativeSession;
	}

	/**
	 * Set whether to check that the Hibernate Session is not in read-only mode
	 * in case of write operations (save/update/delete).
	 * <p>Default is "true", for fail-fast behavior when attempting write operations
	 * within a read-only transaction. Turn this off to allow save/update/delete
	 * on a Session with flush mode NEVER.
	 * @see #setFlushMode
	 * @see #checkWriteOperationAllowed
	 * @see org.springframework.transaction.TransactionDefinition#isReadOnly
	 */
	public void setCheckWriteOperations(boolean checkWriteOperations) {
		this.checkWriteOperations = checkWriteOperations;
	}

	/**
	 * Return whether to check that the Hibernate Session is not in read-only
	 * mode in case of write operations (save/update/delete).
	 */
	public boolean isCheckWriteOperations() {
		return this.checkWriteOperations;
	}

	/**
	 * Set whether to cache all queries executed by this template.
	 * <p>If this is "true", all Query and Criteria objects created by
	 * this template will be marked as cacheable (including all
	 * queries through find methods).
	 * <p>To specify the query region to be used for queries cached
	 * by this template, set the "queryCacheRegion" property.
	 * @see #setQueryCacheRegion
	 * @see org.hibernate.Query#setCacheable
	 * @see org.hibernate.Criteria#setCacheable
	 */
	public void setCacheQueries(boolean cacheQueries) {
		this.cacheQueries = cacheQueries;
	}

	/**
	 * Return whether to cache all queries executed by this template.
	 */
	public boolean isCacheQueries() {
		return this.cacheQueries;
	}

	/**
	 * Set the name of the cache region for queries executed by this template.
	 * <p>If this is specified, it will be applied to all Query and Criteria objects
	 * created by this template (including all queries through find methods).
	 * <p>The cache region will not take effect unless queries created by this
	 * template are configured to be cached via the "cacheQueries" property.
	 * @see #setCacheQueries
	 * @see org.hibernate.Query#setCacheRegion
	 * @see org.hibernate.Criteria#setCacheRegion
	 */
	public void setQueryCacheRegion(String queryCacheRegion) {
		this.queryCacheRegion = queryCacheRegion;
	}

	/**
	 * Return the name of the cache region for queries executed by this template.
	 */
	public String getQueryCacheRegion() {
		return this.queryCacheRegion;
	}

	/**
	 * Set the fetch size for this HibernateTemplate. This is important for processing
	 * large result sets: Setting this higher than the default value will increase
	 * processing speed at the cost of memory consumption; setting this lower can
	 * avoid transferring row data that will never be read by the application.
	 * <p>Default is 0, indicating to use the JDBC driver's default.
	 */
	public void setFetchSize(int fetchSize) {
		this.fetchSize = fetchSize;
	}

	/**
	 * Return the fetch size specified for this HibernateTemplate.
	 */
	public int getFetchSize() {
		return this.fetchSize;
	}

	/**
	 * Set the maximum number of rows for this HibernateTemplate. This is important
	 * for processing subsets of large result sets, avoiding to read and hold
	 * the entire result set in the database or in the JDBC driver if we're
	 * never interested in the entire result in the first place (for example,
	 * when performing searches that might return a large number of matches).
	 * <p>Default is 0, indicating to use the JDBC driver's default.
	 */
	public void setMaxResults(int maxResults) {
		this.maxResults = maxResults;
	}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
不卡的电影网站| 欧美大片拔萝卜| 日韩亚洲电影在线| 亚洲品质自拍视频| 免费在线观看日韩欧美| 91在线精品一区二区| 亚洲精品一区二区三区福利| 亚洲美腿欧美偷拍| 成人亚洲精品久久久久软件| 欧美一区二区视频观看视频| 亚洲夂夂婷婷色拍ww47| 99re视频精品| 欧美激情一区二区| 老司机精品视频一区二区三区| 色婷婷久久久久swag精品| 国产清纯在线一区二区www| 日产国产欧美视频一区精品| 色播五月激情综合网| 国产精品免费免费| 国产乱人伦偷精品视频免下载| 91精品国产综合久久福利软件 | 亚洲一区二区三区四区五区中文| 国内精品伊人久久久久av一坑| 欧美日韩一区成人| 欧美一二区视频| 日韩欧美在线网站| 亚洲图片激情小说| 美女视频黄免费的久久| 精品久久久久香蕉网| 五月综合激情网| 在线看不卡av| 亚洲成人免费影院| 欧美亚洲一区二区在线| 亚洲一区二区四区蜜桃| 欧美无人高清视频在线观看| 亚洲一区二三区| 欧美日韩在线播放一区| 香蕉乱码成人久久天堂爱免费| 欧美日韩视频在线第一区 | 午夜精品123| 欧美日韩一卡二卡三卡 | 中文字幕一区二区日韩精品绯色| 国产69精品久久777的优势| 中文字幕欧美日韩一区| 99久久精品国产网站| 亚洲精品视频在线观看网站| 在线观看一区日韩| 午夜伊人狠狠久久| 日韩一区二区视频| 国产一区二区三区在线观看精品 | 91精品国产一区二区| 老司机精品视频一区二区三区| 久久综合成人精品亚洲另类欧美| 国产精品88av| 亚洲精品国产a久久久久久| 欧美精品乱人伦久久久久久| 久久精品噜噜噜成人av农村| 中文字幕乱码久久午夜不卡| 色婷婷激情久久| 日韩 欧美一区二区三区| 久久久久久久久久电影| 色婷婷综合久久| 精品无人码麻豆乱码1区2区| 中文成人综合网| 欧美日韩国产影片| 成人永久免费视频| 亚洲成av人片| 国产精品日韩精品欧美在线| 欧美日韩一区视频| 国产成人综合网站| 性感美女久久精品| 国产精品久久久久久久久图文区| 欧美人与性动xxxx| 99视频一区二区| 日韩中文字幕一区二区三区| 国产欧美日韩精品在线| 欧美精品高清视频| 97se亚洲国产综合自在线不卡 | 一区二区三区中文字幕电影| 日韩免费一区二区三区在线播放| 99精品视频在线观看| 日本不卡一区二区三区| 中文字幕在线播放不卡一区| 在线不卡欧美精品一区二区三区| 成人av免费在线观看| 久久精品99久久久| 亚洲成av人片在www色猫咪| 国产精品毛片a∨一区二区三区| 欧美放荡的少妇| 91久久人澡人人添人人爽欧美| 国产综合一区二区| 日本中文在线一区| 亚洲一二三四在线观看| 国产精品久久久久久久浪潮网站 | 欧美中文字幕一区二区三区亚洲| 精品一区二区三区免费毛片爱| 亚洲第一福利视频在线| 1024国产精品| 亚洲国产成人一区二区三区| 久久久综合精品| 精品久久久久久久久久久久久久久久久 | av成人动漫在线观看| 韩国成人精品a∨在线观看| 免费久久99精品国产| 一区二区不卡在线播放| ㊣最新国产の精品bt伙计久久| 久久久不卡影院| 久久综合中文字幕| 久久综合五月天婷婷伊人| 日韩欧美aaaaaa| 精品久久人人做人人爱| 日韩精品一区二区三区四区 | 韩国成人在线视频| 韩国午夜理伦三级不卡影院| 黑人巨大精品欧美一区| 国产呦萝稀缺另类资源| 狠狠色丁香久久婷婷综合_中| 久久国产三级精品| 久久精品国产一区二区| 青青草视频一区| 国内精品不卡在线| 国产精品18久久久久久久久| 国产麻豆精品在线| 成人午夜又粗又硬又大| 成人a区在线观看| 色乱码一区二区三区88| 欧美色综合天天久久综合精品| 日本高清不卡aⅴ免费网站| 欧美视频中文一区二区三区在线观看 | 国产**成人网毛片九色 | 精品亚洲成a人在线观看| 精品一区二区三区影院在线午夜 | 欧美三级一区二区| 欧美精品777| 337p粉嫩大胆噜噜噜噜噜91av| 精品理论电影在线观看| 中文字幕中文字幕在线一区 | 日本一区二区三区国色天香| 国产精品传媒入口麻豆| 亚洲图片欧美色图| 国产一区二三区| 91在线一区二区三区| 欧美日韩视频在线观看一区二区三区| 欧美一区二区三区四区在线观看| 久久亚洲二区三区| 一区二区高清在线| 国产一区激情在线| 在线观看亚洲精品| 日韩一区二区三区在线观看| 国产精品网站在线观看| 亚洲 欧美综合在线网络| 精一区二区三区| 色噜噜狠狠成人中文综合| 日韩欧美在线一区二区三区| 综合欧美亚洲日本| 美国十次综合导航| 色噜噜狠狠成人网p站| 亚洲精品一区二区三区四区高清| 亚洲欧美电影一区二区| 久久精品国产免费看久久精品| av电影在线不卡| 亚洲精品一线二线三线| 亚洲成人在线免费| av爱爱亚洲一区| 日韩欧美在线1卡| 亚洲精品五月天| 粉嫩av一区二区三区在线播放 | 欧美精品在线一区二区三区| 国产色婷婷亚洲99精品小说| 婷婷丁香久久五月婷婷| av资源站一区| 久久久亚洲精华液精华液精华液| 亚洲一区二区精品3399| 99re这里都是精品| 久久久91精品国产一区二区精品 | 日韩一区二区三区三四区视频在线观看 | 亚洲一卡二卡三卡四卡五卡| 国产成人精品在线看| 欧美顶级少妇做爰| 亚洲高清三级视频| 在线视频中文字幕一区二区| 国产精品久久久久久一区二区三区| 美国一区二区三区在线播放| 欧美精品三级日韩久久| 一二三区精品视频| 91丨九色丨国产丨porny| 国产亚洲精品福利| 韩国欧美国产1区| 亚洲精品一区二区三区蜜桃下载| 日本少妇一区二区| 91精品国产综合久久久蜜臀粉嫩| 亚洲一区二区三区自拍| 在线观看www91| 一区二区视频在线| 91日韩在线专区| 亚洲精品免费电影| 色天使色偷偷av一区二区| 亚洲天堂2016| 欧美天堂一区二区三区| 亚洲3atv精品一区二区三区|