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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? toplinktemplate.java

?? spring framework 2.5.4源代碼
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/*
 * Copyright 2002-2007 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.toplink;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;

import oracle.toplink.exceptions.TopLinkException;
import oracle.toplink.expressions.Expression;
import oracle.toplink.queryframework.Call;
import oracle.toplink.queryframework.DatabaseQuery;
import oracle.toplink.queryframework.ReadObjectQuery;
import oracle.toplink.sessions.ObjectCopyingPolicy;
import oracle.toplink.sessions.Session;
import oracle.toplink.sessions.UnitOfWork;

import org.springframework.dao.DataAccessException;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.orm.ObjectRetrievalFailureException;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

/**
 * Helper class that simplifies TopLink data access code, and converts
 * TopLinkExceptions into unchecked DataAccessExceptions, following the
 * <code>org.springframework.dao</code> exception hierarchy.
 *
 * <p>The central method is <code>execute</code>, supporting TopLink access code
 * implementing the {@link TopLinkCallback} interface. It provides TopLink Session
 * handling such that neither the TopLinkCallback implementation nor the calling
 * code needs to explicitly care about retrieving/closing TopLink Sessions,
 * or handling Session lifecycle exceptions. For typical single step actions,
 * there are various convenience methods (read, readAll, merge, delete, etc).
 *
 * <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>This class can be considered as direct alternative to working with the raw
 * TopLink Session API (through <code>SessionFactoryUtils.getSession()</code>).
 * The major advantage is its automatic conversion to DataAccessExceptions, the
 * major disadvantage that no checked application exceptions can get thrown from
 * within data access code. Corresponding checks and the actual throwing of such
 * exceptions can often be deferred to after callback execution, though.
 *
 * <p>{@link LocalSessionFactoryBean} is the preferred way of obtaining a reference
 * to a specific TopLink SessionFactory. It will usually be configured to
 * create ClientSessions for a ServerSession held by it, allowing for seamless
 * multi-threaded execution. The Spring application context will manage its lifecycle,
 * initializing and shutting down the factory as part of the application.
 *
 * <p>Thanks to Slavik Markovich for implementing the initial TopLink support prototype!
 *
 * @author Juergen Hoeller
 * @author <a href="mailto:james.x.clark@oracle.com">James Clark</a>
 * @since 1.2
 * @see #setSessionFactory
 * @see TopLinkCallback
 * @see oracle.toplink.sessions.Session
 * @see TopLinkInterceptor
 * @see LocalSessionFactoryBean
 * @see TopLinkTransactionManager
 * @see org.springframework.transaction.jta.JtaTransactionManager
 */
public class TopLinkTemplate extends TopLinkAccessor implements TopLinkOperations {

	private boolean allowCreate = true;


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

	/**
	 * Create a new TopLinkTemplate instance.
	 */
	public TopLinkTemplate(SessionFactory sessionFactory) {
		setSessionFactory(sessionFactory);
		afterPropertiesSet();
	}

	/**
	 * Create a new TopLinkTemplate instance.
	 * @param allowCreate if a new Session should be created if no thread-bound found
	 */
	public TopLinkTemplate(SessionFactory sessionFactory, boolean allowCreate) {
		setSessionFactory(sessionFactory);
		setAllowCreate(allowCreate);
		afterPropertiesSet();
	}

	/**
	 * Set if a new Session should be created when no transactional Session
	 * can be found for the current thread.
	 * <p>TopLinkTemplate is aware of a corresponding Session bound to the
	 * current thread, for example when using TopLinkTransactionManager.
	 * If allowCreate is true, a new non-transactional Session will be created
	 * if none found, which needs to be closed at the end of the operation.
	 * If false, an IllegalStateException will get thrown in this case.
	 * @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;
	}


	public Object execute(TopLinkCallback action) throws DataAccessException {
		Assert.notNull(action, "Callback object must not be null");

		Session session = SessionFactoryUtils.getSession(getSessionFactory(), this.allowCreate);
		try {
			return action.doInTopLink(session);
		}
		catch (TopLinkException ex) {
			throw convertTopLinkAccessException(ex);
		}
		catch (RuntimeException ex) {
			// callback code threw application exception
			throw ex;
		}
		finally {
			SessionFactoryUtils.releaseSession(session, getSessionFactory());
		}
	}

	public List executeFind(TopLinkCallback action) throws DataAccessException {
		Object result = execute(action);
		if (result != null && !(result instanceof List)) {
			throw new InvalidDataAccessApiUsageException(
					"Result object returned from TopLinkCallback isn't a List: [" + result + "]");
		}
		return (List) result;
	}


	//-------------------------------------------------------------------------
	// Convenience methods for executing generic queries
	//-------------------------------------------------------------------------

	public Object executeNamedQuery(Class entityClass, String queryName) throws DataAccessException {
		return executeNamedQuery(entityClass, queryName, null, false);
	}

	public Object executeNamedQuery(Class entityClass, String queryName, boolean enforceReadOnly)
			throws DataAccessException {

		return executeNamedQuery(entityClass, queryName, null, enforceReadOnly);
	}

	public Object executeNamedQuery(Class entityClass, String queryName, Object[] args)
			throws DataAccessException {

		return executeNamedQuery(entityClass, queryName, args, false);
	}

	public Object executeNamedQuery(
			final Class entityClass, final String queryName, final Object[] args, final boolean enforceReadOnly)
			throws DataAccessException {

		return execute(new SessionReadCallback(enforceReadOnly) {
			protected Object readFromSession(Session session) throws TopLinkException {
				if (args != null) {
					return session.executeQuery(queryName, entityClass, new Vector(Arrays.asList(args)));
				}
				else {
					return session.executeQuery(queryName, entityClass, new Vector());
				}
			}
		});
	}

	public Object executeQuery(DatabaseQuery query) throws DataAccessException {
		return executeQuery(query, null, false);
	}

	public Object executeQuery(DatabaseQuery query, boolean enforceReadOnly) throws DataAccessException {
		return executeQuery(query, null, enforceReadOnly);
	}

	public Object executeQuery(DatabaseQuery query, Object[] args) throws DataAccessException {
		return executeQuery(query, args, false);
	}

	public Object executeQuery(final DatabaseQuery query, final Object[] args, final boolean enforceReadOnly)
			throws DataAccessException {

		return execute(new SessionReadCallback(enforceReadOnly) {
			protected Object readFromSession(Session session) throws TopLinkException {
				if (args != null) {
					return session.executeQuery(query, new Vector(Arrays.asList(args)));
				}
				else {
					return session.executeQuery(query);
				}
			}
		});
	}


	//-------------------------------------------------------------------------
	// Convenience methods for reading a specific set of objects
	//-------------------------------------------------------------------------

	public List readAll(Class entityClass) throws DataAccessException {
		return readAll(entityClass, false);
	}

	public List readAll(final Class entityClass, final boolean enforceReadOnly) throws DataAccessException {
		return executeFind(new SessionReadCallback(enforceReadOnly) {
			protected Object readFromSession(Session session) throws TopLinkException {
				return session.readAllObjects(entityClass);
			}
		});
	}

	public List readAll(Class entityClass, Expression expression) throws DataAccessException {
		return readAll(entityClass, expression, false);
	}

	public List readAll(final Class entityClass, final Expression expression, final boolean enforceReadOnly)
			throws DataAccessException {

		return executeFind(new SessionReadCallback(enforceReadOnly) {
			protected Object readFromSession(Session session) throws TopLinkException {
				return session.readAllObjects(entityClass, expression);
			}
		});
	}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久人人97超碰com| 色琪琪一区二区三区亚洲区| 五月婷婷综合激情| 亚洲激情第一区| 亚洲免费在线观看视频| 国产精品久久久久久福利一牛影视| 欧美videos大乳护士334| 日韩一区二区三区观看| 日韩一二三区视频| 久久这里只有精品6| 国产亚洲欧美在线| 亚洲色图清纯唯美| 亚洲一级电影视频| 蜜臀av一区二区三区| 国产在线播放一区三区四| 国产伦精一区二区三区| 91丝袜呻吟高潮美腿白嫩在线观看| 国产经典欧美精品| 色欲综合视频天天天| 欧美综合一区二区| 日韩欧美在线一区二区三区| 久久五月婷婷丁香社区| 成人欧美一区二区三区1314| 一区二区三区欧美日| 偷拍一区二区三区四区| 国产精品66部| 91免费观看国产| 91精品国产一区二区三区蜜臀 | 日日嗨av一区二区三区四区| 麻豆精品一区二区综合av| 国产精品99久久久久| 91国内精品野花午夜精品 | 国产欧美日韩在线观看| 亚洲视频在线观看三级| 免费观看一级欧美片| 国产99久久久国产精品潘金网站| 欧美疯狂做受xxxx富婆| 久久久久久9999| 亚洲自拍欧美精品| 国产一区二区精品久久99| 欧美制服丝袜第一页| 久久久精品国产免费观看同学| 亚洲一区在线播放| 国产一区二区91| 777色狠狠一区二区三区| 国产精品超碰97尤物18| 免费成人小视频| 91久久精品一区二区三| 国产亚洲精品bt天堂精选| 日韩精品亚洲一区二区三区免费| 97精品电影院| 国产午夜精品美女毛片视频| 日韩综合一区二区| 在线中文字幕不卡| 国产精品久久久久久久久果冻传媒| 久久精品久久精品| 欧美日韩一级大片网址| 亚洲精品视频在线观看免费| 成人性生交大片免费看中文| 精品国产精品一区二区夜夜嗨| 亚洲二区视频在线| 91国在线观看| 一区二区三区日韩欧美| 91丨国产丨九色丨pron| 中文字幕精品在线不卡| 国产精品1区2区3区| 精品久久久影院| 精品在线播放免费| 精品国产污网站| 国内久久精品视频| 亚洲精品一区在线观看| 韩国女主播一区| 国产视频一区二区三区在线观看| 精品制服美女丁香| 精品福利一区二区三区| 蜜桃一区二区三区在线观看| 91精品免费观看| 美国欧美日韩国产在线播放| 日韩三级.com| 韩日欧美一区二区三区| 久久看人人爽人人| 国产福利91精品一区二区三区| 久久久美女艺术照精彩视频福利播放| 久久精品国产在热久久| 国产三级欧美三级日产三级99| 国产一区二区美女| 国产精品久久久久永久免费观看| av在线播放成人| 亚洲18色成人| 欧美成人一区二区| 丁香一区二区三区| 亚洲色图在线看| 欧美精品乱人伦久久久久久| 久久99国产精品久久| 欧美激情综合网| 色吧成人激情小说| 日韩电影在线观看网站| 久久久久9999亚洲精品| gogogo免费视频观看亚洲一| 亚洲美女免费在线| 日韩一区二区高清| 成人免费视频播放| 亚洲一区二区视频在线| 日韩免费电影一区| 成人av综合一区| 天天亚洲美女在线视频| 久久久久久久久久久久电影| 在线看日韩精品电影| 麻豆中文一区二区| 国产精品福利电影一区二区三区四区| 在线视频你懂得一区二区三区| 蜜臀av一区二区在线免费观看| 欧美高清一级片在线观看| 欧美日韩国产乱码电影| 国产成人免费在线观看不卡| 天堂久久久久va久久久久| 中文字幕精品一区二区三区精品 | 日日夜夜免费精品| 亚洲国产激情av| 91精品国产麻豆| av一二三不卡影片| 久久国产精品免费| 亚洲国产视频一区二区| 日韩精品一区二区三区视频在线观看| 波多野结衣一区二区三区| 青青国产91久久久久久| 亚洲乱码日产精品bd| 亚洲精品一线二线三线| 制服丝袜日韩国产| 97se亚洲国产综合在线| 国产一区二区视频在线播放| 亚洲成人在线免费| 亚洲男帅同性gay1069| 久久久无码精品亚洲日韩按摩| 欧美日韩综合一区| 白白色 亚洲乱淫| 国产成人欧美日韩在线电影| 理论电影国产精品| 五月综合激情网| 一区二区三区四区不卡视频| 中文av一区特黄| 337p粉嫩大胆色噜噜噜噜亚洲| 91精品国产美女浴室洗澡无遮挡| 91在线一区二区三区| 成人h版在线观看| 成人免费视频app| 成人免费视频app| 国产麻豆9l精品三级站| 国产在线一区二区综合免费视频| 九九热在线视频观看这里只有精品| 午夜精品一区在线观看| 亚洲电影在线播放| 香蕉加勒比综合久久| 亚洲一级二级在线| 午夜精品久久一牛影视| 丝袜诱惑亚洲看片| 美腿丝袜在线亚洲一区| 人妖欧美一区二区| 肉色丝袜一区二区| 精品无人区卡一卡二卡三乱码免费卡| 日本最新不卡在线| 久久超级碰视频| 国产成人午夜高潮毛片| 成人av网站在线| 91美女视频网站| 91国内精品野花午夜精品| 欧美日韩国产小视频在线观看| 91精品国产aⅴ一区二区| 日韩欧美亚洲一区二区| 久久久午夜电影| 亚洲欧洲日韩综合一区二区| 亚洲制服欧美中文字幕中文字幕| 亚洲午夜免费视频| 久久成人久久爱| 99久久精品免费精品国产| 色偷偷88欧美精品久久久| 欧美日韩高清一区二区三区| 欧美一卡二卡三卡| 国产精品网站在线播放| 亚洲第一成人在线| 国产精品一区二区在线看| 91在线视频官网| 日韩一区二区免费在线电影 | 欧美在线影院一区二区| 日韩欧美一区二区免费| 国产精品美女久久久久久久久| 亚洲人吸女人奶水| 免费人成在线不卡| 丁香亚洲综合激情啪啪综合| 欧美性做爰猛烈叫床潮| www日韩大片| 亚洲图片欧美综合| 国产一区二区在线视频| 欧美午夜精品免费| 久久九九国产精品| 石原莉奈在线亚洲二区| 91在线观看高清| 精品区一区二区| 亚洲综合激情另类小说区| 国产福利91精品一区|