当前位置: 首页>>代码示例>>Java>>正文


Java Filter类代码示例

本文整理汇总了Java中org.hibernate.Filter的典型用法代码示例。如果您正苦于以下问题:Java Filter类的具体用法?Java Filter怎么用?Java Filter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Filter类属于org.hibernate包,在下文中一共展示了Filter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFilterQueryPlan

import org.hibernate.Filter; //导入依赖的package包/类
/**
 * Get the query plan for the given collection HQL filter fragment, creating it and caching it if not already cached
 *
 * @param filterString The HQL filter fragment
 * @param collectionRole The collection being filtered
 * @param shallow Whether the execution will be shallow
 * @param enabledFilters The filters enabled on the Session
 *
 * @return The query plan
 *
 * @throws QueryException Indicates a problem translating the query
 * @throws MappingException Indicates a problem translating the query
 */
@SuppressWarnings("unchecked")
public FilterQueryPlan getFilterQueryPlan(
		String filterString,
		String collectionRole,
		boolean shallow,
		Map<String,Filter> enabledFilters) throws QueryException, MappingException {
	final FilterQueryPlanKey key =  new FilterQueryPlanKey( filterString, collectionRole, shallow, enabledFilters );
	FilterQueryPlan value = (FilterQueryPlan) queryPlanCache.get( key );
	if ( value == null ) {
		LOG.tracev(
				"Unable to locate collection-filter query plan in cache; generating ({0} : {1} )",
				collectionRole,
				filterString
		);
		value = new FilterQueryPlan( filterString, collectionRole, shallow, enabledFilters,factory );
		queryPlanCache.putIfAbsent( key, value );
	}
	else {
		LOG.tracev( "Located collection-filter query plan in cache ({0} : {1})", collectionRole, filterString );
	}
	return value;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:36,代码来源:QueryPlanCache.java

示例2: setParameterList

import org.hibernate.Filter; //导入依赖的package包/类
/**
 * Set the named parameter's value list for this filter.  Used
 * in conjunction with IN-style filter criteria.
 *
 * @param name   The parameter's name.
 * @param values The values to be expanded into an SQL IN list.
 * @return This FilterImpl instance (for method chaining).
 */
public Filter setParameterList(String name, Collection values) throws HibernateException  {
	// Make sure this is a defined parameter and check the incoming value type
	if ( values == null ) {
		throw new IllegalArgumentException( "Collection must be not null!" );
	}
	Type type = definition.getParameterType( name );
	if ( type == null ) {
		throw new HibernateException( "Undefined filter parameter [" + name + "]" );
	}
	if ( !values.isEmpty() ) {
		Class elementClass = values.iterator().next().getClass();
		if ( !type.getReturnedClass().isAssignableFrom( elementClass ) ) {
			throw new HibernateException( "Incorrect type for parameter [" + name + "]" );
		}
	}
	parameters.put( name, values );
	return this;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:FilterImpl.java

示例3: createFilterKeys

import org.hibernate.Filter; //导入依赖的package包/类
/**
 * Constructs a number of FilterKey instances, given the currently enabled filters
 *
 * @param enabledFilters The currently enabled filters
 *
 * @return The filter keys, one per enabled filter
 */
public static Set<FilterKey> createFilterKeys(Map<String,Filter> enabledFilters) {
	if ( enabledFilters.size() == 0 ) {
		return null;
	}
	final Set<FilterKey> result = new HashSet<FilterKey>();
	for ( Filter filter : enabledFilters.values() ) {
		final FilterKey key = new FilterKey(
				filter.getName(),
				( (FilterImpl) filter ).getParameters(),
				filter.getFilterDefinition().getParameterTypes()
		);
		result.add( key );
	}
	return result;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:FilterKey.java

示例4: testExecuteWithThreadBoundAndParameterizedFilter

import org.hibernate.Filter; //导入依赖的package包/类
@Test
public void testExecuteWithThreadBoundAndParameterizedFilter() {
	Filter filter = mock(Filter.class);
	given(session.isOpen()).willReturn(true);
	given(session.enableFilter("myFilter")).willReturn(filter);
	hibernateTemplate.setAllowCreate(false);
	hibernateTemplate.setFilterName("myFilter");

	TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session));
	try {
		final List l = new ArrayList();
		l.add("test");
		Filter f = hibernateTemplate.enableFilter("myFilter");
		assertTrue("Correct filter", f == filter);
	}
	finally {
		TransactionSynchronizationManager.unbindResource(sessionFactory);
	}
	InOrder ordered = inOrder(session);
	ordered.verify(session).getEnabledFilter("myFilter");
	ordered.verify(session).enableFilter("myFilter");
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:23,代码来源:HibernateTemplateTests.java

示例5: testExecuteWithThreadBoundAndParameterizedExistingFilter

import org.hibernate.Filter; //导入依赖的package包/类
@Test
public void testExecuteWithThreadBoundAndParameterizedExistingFilter() {
	Filter filter = mock(Filter.class);
	given(session.isOpen()).willReturn(true);
	given(session.enableFilter("myFilter")).willReturn(filter);
	hibernateTemplate.setAllowCreate(false);
	hibernateTemplate.setFilterName("myFilter");

	TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session));
	try {
		final List l = new ArrayList();
		l.add("test");
		Filter f = hibernateTemplate.enableFilter("myFilter");
		assertTrue("Correct filter", f == filter);
	}
	finally {
		TransactionSynchronizationManager.unbindResource(sessionFactory);
	}
	verify(session).getEnabledFilter("myFilter");
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:21,代码来源:HibernateTemplateTests.java

示例6: setParameterList

import org.hibernate.Filter; //导入依赖的package包/类
/**
 * Set the named parameter's value list for this filter.  Used
 * in conjunction with IN-style filter criteria.
 *
 * @param name   The parameter's name.
 * @param values The values to be expanded into an SQL IN list.
 * @return This FilterImpl instance (for method chaining).
 */
public Filter setParameterList(String name, Collection values) throws HibernateException  {
	// Make sure this is a defined parameter and check the incoming value type
	if ( values == null ) {
		throw new IllegalArgumentException( "Collection must be not null!" );
	}
	Type type = definition.getParameterType( name );
	if ( type == null ) {
		throw new HibernateException( "Undefined filter parameter [" + name + "]" );
	}
	if ( values.size() > 0 ) {
		Class elementClass = values.iterator().next().getClass();
		if ( !type.getReturnedClass().isAssignableFrom( elementClass ) ) {
			throw new HibernateException( "Incorrect type for parameter [" + name + "]" );
		}
	}
	parameters.put( name, values );
	return this;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:27,代码来源:FilterImpl.java

示例7: configureHibernateGlobalFilter

import org.hibernate.Filter; //导入依赖的package包/类
private void configureHibernateGlobalFilter(Filter filter) {
  String filterLanguage = null;
  if (getLocale() != null) {
    filterLanguage = getLocale().getLanguage();
  }
  if (filterLanguage == null) {
    filterLanguage = "";
  }
  String filterLogin = null;
  if (getApplicationSession().getPrincipal() != null) {
    filterLogin = getApplicationSession().getUsername();
  }
  if (filterLogin == null) {
    filterLogin = "";
  }
  filter.setParameter(JSPRESSO_SESSION_GLOBALS_LANGUAGE, filterLanguage);
  filter.setParameter(JSPRESSO_SESSION_GLOBALS_LOGIN, filterLogin);
}
 
开发者ID:jspresso,项目名称:jspresso-ce,代码行数:19,代码来源:HibernateBackendController.java

示例8: doBefore

import org.hibernate.Filter; //导入依赖的package包/类
public void doBefore(final JoinPoint joinPoint,
		final EntityFilter annotation) {

	Filter f = sessionFactory.getCurrentSession().enableFilter(
			annotation.filter());
	String expression;
	Integer paramNumber;
	Expression exp;
	Object subject;
	Object[] params = joinPoint.getArgs();
	for (FilterAttribute attribute : annotation.params()) {
		if (ELParser.isMethodParamExpression(attribute.path())) {
			paramNumber = ELParser.getParamNumber(attribute.path());
			expression = ELParser.removeParamNumber(attribute.path());
			exp = parser.parseExpression(expression);
			subject = params[paramNumber];
		} else {
			exp = parser.parseExpression(attribute.path());
			subject = joinPoint.getTarget();
		}
		f.setParameter(attribute.name(), exp.getValue(subject));
	}
}
 
开发者ID:fpuna-cia,项目名称:karaku,代码行数:24,代码来源:KarakuEntityFilterHandler.java

示例9: enableFilter

import org.hibernate.Filter; //导入依赖的package包/类
public void enableFilter(Session session) {
	Client client = (Client) sessionObjectsService.getSessionObject(ClientContextObjectContributor.CONTEXT_OBJECT_CLIENT_NAME);
	if (client != null) {
		LOG.debug("New session created, enabling filter for client selection");
		Filter filter = session.enableFilter(CLIENT_FILTER_NAME);
		filter.setParameter("client", client.getId());
		List<String> organizationList = new ArrayList<String>();
		for (Organization org : ((Client) session.get(Client.class, client.getId())).getOrganizations()) {
			organizationList.add(org.getId());
		}
		filter = session.enableFilter(CLIENT_ORGANIZATION_FILTER_NAME);
		if (organizationList.size() == 0) {
			organizationList.add("NULL_EXPECT_NEVER_HAS_THIS_KEY_BECAUSE_THE_STRING_HAS_MORE_LEN THAN THE PERMITTED_KEY");
		}
		filter.setParameterList("organizationList", organizationList);

	} else {
		LOG.debug("Client filter not enabling because client is not established");
	}

}
 
开发者ID:frincon,项目名称:openeos,代码行数:22,代码来源:ClientFilterProvider.java

示例10: switchFilter

import org.hibernate.Filter; //导入依赖的package包/类
private boolean switchFilter(String filter, CfFlowState flowType, Date startDate, Date endDate, Class clazz, Session session) {
    log.debug("filter:" + filter);
    log.debug("clazz:" + clazz);

    Filter hqlFilter;
    try {
        if (filter == null) filter = "";
        if (null == flowType) {
            hqlFilter = session.enableFilter("filter3_" + clazz.getSimpleName());
            hqlFilter.setParameter("filter", "%" + filter + "%");
            hqlFilter.setParameter("startDate", startDate);
            hqlFilter.setParameter("endDate", endDate);
        } else {
            hqlFilter = session.enableFilter("filter4_" + clazz.getSimpleName());
            hqlFilter.setParameter("filter", "%" + filter + "%");
            hqlFilter.setParameter("flowState", flowType.ordinal());
            hqlFilter.setParameter("startDate", startDate);
            hqlFilter.setParameter("endDate", endDate);
        }
    } catch (Exception e) {
        e.printStackTrace();
        return true;
    }
    return false;
}
 
开发者ID:rafizanbaharum,项目名称:cfi-gov,代码行数:26,代码来源:CfAclDaoImpl.java

示例11: enableFilter

import org.hibernate.Filter; //导入依赖的package包/类
@Override
public Filter enableFilter(String filterName) throws IllegalStateException {
	Session session = getSessionFactory().getCurrentSession();
	Filter filter = session.getEnabledFilter(filterName);
	if (filter == null) {
		filter = session.enableFilter(filterName);
	}
	return filter;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:HibernateTemplate.java

示例12: enableFilter

import org.hibernate.Filter; //导入依赖的package包/类
@Override
public Filter enableFilter(String filterName) throws IllegalStateException {
	Session session = SessionFactoryUtils.getSession(getSessionFactory(), false);
	Filter filter = session.getEnabledFilter(filterName);
	if (filter == null) {
		filter = session.enableFilter(filterName);
	}
	return filter;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:HibernateTemplate.java

示例13: getHQLQueryPlan

import org.hibernate.Filter; //导入依赖的package包/类
/**
 * Get the query plan for the given HQL query, creating it and caching it if not already cached
 *
 * @param queryString The HQL query string
 * @param shallow Whether the execution will be shallow
 * @param enabledFilters The filters enabled on the Session
 *
 * @return The query plan
 *
 * @throws QueryException Indicates a problem translating the query
 * @throws MappingException Indicates a problem translating the query
 */
@SuppressWarnings("unchecked")
public HQLQueryPlan getHQLQueryPlan(String queryString, boolean shallow, Map<String,Filter> enabledFilters)
		throws QueryException, MappingException {
	final HQLQueryPlanKey key = new HQLQueryPlanKey( queryString, shallow, enabledFilters );
	HQLQueryPlan value = (HQLQueryPlan) queryPlanCache.get( key );
	if ( value == null ) {
		LOG.tracev( "Unable to locate HQL query plan in cache; generating ({0})", queryString );
		value = new HQLQueryPlan( queryString, shallow, enabledFilters, factory );
		queryPlanCache.putIfAbsent( key, value );
	} else {
		LOG.tracev( "Located HQL query plan in cache ({0})", queryString );
	}
	return value;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:QueryPlanCache.java

示例14: getEnabledFilters

import org.hibernate.Filter; //导入依赖的package包/类
public Map<String,Filter> getEnabledFilters() {
	// First, validate all the enabled filters...
	//TODO: this implementation has bad performance
	for ( Filter filter : enabledFilters.values() ) {
		filter.validate();
	}
	return enabledFilters;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:LoadQueryInfluencers.java

示例15: setParameter

import org.hibernate.Filter; //导入依赖的package包/类
/**
 * Set the named parameter's value for this filter.
 *
 * @param name The parameter's name.
 * @param value The value to be applied.
 * @return This FilterImpl instance (for method chaining).
 * @throws IllegalArgumentException Indicates that either the parameter was undefined or that the type
 * of the passed value did not match the configured type.
 */
public Filter setParameter(String name, Object value) throws IllegalArgumentException {
	// Make sure this is a defined parameter and check the incoming value type
	// TODO: what should be the actual exception type here?
	Type type = definition.getParameterType( name );
	if ( type == null ) {
		throw new IllegalArgumentException( "Undefined filter parameter [" + name + "]" );
	}
	if ( value != null && !type.getReturnedClass().isAssignableFrom( value.getClass() ) ) {
		throw new IllegalArgumentException( "Incorrect type for parameter [" + name + "]" );
	}
	parameters.put( name, value );
	return this;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:FilterImpl.java


注:本文中的org.hibernate.Filter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。