queryimpl.java
来自「用Java实现的23个常用设计模式源代码」· Java 代码 · 共 73 行
JAVA
73 行
//$Id: QueryImpl.java,v 1.19.2.7 2003/11/02 08:56:48 oneovthafew Exp $package net.sf.hibernate.impl;import java.util.Iterator;import java.util.List;import java.util.Map;import net.sf.hibernate.HibernateException;import net.sf.hibernate.Query;import net.sf.hibernate.ScrollableResults;import net.sf.hibernate.engine.QueryParameters;import net.sf.hibernate.engine.SessionImplementor;/** * default implementation of the <tt>Query</tt> interface, * for "ordinary" HQL queries (not collection filters) * @see FilterImpl * @author Gavin King */public class QueryImpl extends AbstractQueryImpl { private boolean cacheable; private String cacheRegion; public QueryImpl(String queryString, SessionImplementor session) { super(queryString, session); this.cacheRegion = null; } public Iterator iterate() throws HibernateException { verifyParameters(); Map namedParams = getNamedParams(); return getSession().iterate( bindParameterLists(namedParams), getQueryParameters(namedParams) ); } public ScrollableResults scroll() throws HibernateException { verifyParameters(); Map namedParams = getNamedParams(); return getSession().scroll( bindParameterLists(namedParams), getQueryParameters(namedParams) ); } public List list() throws HibernateException { verifyParameters(); Map namedParams = getNamedParams(); return getSession().find( bindParameterLists(namedParams), getQueryParameters(namedParams) ); } public Query setCacheable(boolean cacheable) { this.cacheable = cacheable; return this; } public Query setCacheRegion(String cacheRegion) { this.cacheRegion = cacheRegion.trim(); return this; } public QueryParameters getQueryParameters(Map namedParams) { QueryParameters result = super.getQueryParameters(namedParams); result.setCacheable(cacheable); result.setCacheRegion(cacheRegion); return result; } }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?