org.hibernate.engine.FilterDefinition Java Examples

The following examples show how to use org.hibernate.engine.FilterDefinition. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HbmBinder.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static void parseFilterDef(Element element, Mappings mappings) {
	String name = element.attributeValue( "name" );
	log.debug( "Parsing filter-def [" + name + "]" );
	String defaultCondition = element.getTextTrim();
	if ( StringHelper.isEmpty( defaultCondition ) ) {
		defaultCondition = element.attributeValue( "condition" );
	}
	HashMap paramMappings = new HashMap();
	Iterator params = element.elementIterator( "filter-param" );
	while ( params.hasNext() ) {
		final Element param = (Element) params.next();
		final String paramName = param.attributeValue( "name" );
		final String paramType = param.attributeValue( "type" );
		log.debug( "adding filter parameter : " + paramName + " -> " + paramType );
		final Type heuristicType = TypeFactory.heuristicType( paramType );
		log.debug( "parameter heuristic type : " + heuristicType );
		paramMappings.put( paramName, heuristicType );
	}
	log.debug( "Parsed filter-def [" + name + "]" );
	FilterDefinition def = new FilterDefinition( name, defaultCondition, paramMappings );
	mappings.addFilterDefinition( def );
}
 
Example #2
Source File: SessionFactoryImpl.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public FilterDefinition getFilterDefinition(String filterName) throws HibernateException {
	FilterDefinition def = ( FilterDefinition ) filters.get( filterName );
	if ( def == null ) {
		throw new HibernateException( "No such filter configured [" + filterName + "]" );
	}
	return def;
}
 
Example #3
Source File: SessionImpl.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Type getFilterParameterType(String filterParameterName) {
	errorIfClosed();
	checkTransactionSynchStatus();
	String[] parsed = parseFilterParameterName(filterParameterName);
	FilterDefinition filterDef = factory.getFilterDefinition( parsed[0] );
	if (filterDef == null) {
		throw new IllegalArgumentException("Filter [" + parsed[0] + "] not defined");
	}
	Type type = filterDef.getParameterType( parsed[1] );
	if (type == null) {
		// this is an internal error of some sort...
		throw new InternalError("Unable to locate type for filter parameter");
	}
	return type;
}
 
Example #4
Source File: LocalSessionFactoryBeanTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected Configuration newConfiguration() throws HibernateException {
	return new Configuration() {
		@Override
		public void addFilterDefinition(FilterDefinition definition) {
			registeredFilterDefinitions.add(definition);
		}
	};
}
 
Example #5
Source File: FilterDefinitionFactoryBean.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public FilterDefinition getObject() {
	return this.filterDefinition;
}
 
Example #6
Source File: FilterImpl.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public FilterDefinition getFilterDefinition() {
	return definition;
}
 
Example #7
Source File: SessionFactoryStub.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public FilterDefinition getFilterDefinition(String filterName) throws HibernateException {
	return getImpl().getFilterDefinition( filterName );
}
 
Example #8
Source File: Mappings.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public FilterDefinition getFilterDefinition(String name) {
	return (FilterDefinition) filterDefinitions.get(name);
}
 
Example #9
Source File: Mappings.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void addFilterDefinition(FilterDefinition definition) {
	filterDefinitions.put( definition.getFilterName(), definition );
}
 
Example #10
Source File: Configuration.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void addFilterDefinition(FilterDefinition definition) {
	filterDefinitions.put( definition.getFilterName(), definition );
}
 
Example #11
Source File: FilterDefinitionFactoryBean.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public Class<FilterDefinition> getObjectType() {
	return FilterDefinition.class;
}
 
Example #12
Source File: FilterDefinitionFactoryBean.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public FilterDefinition getObject() {
	return this.filterDefinition;
}
 
Example #13
Source File: FilterDefinitionFactoryBean.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public void afterPropertiesSet() {
	this.filterDefinition =
			new FilterDefinition(this.filterName, this.defaultFilterCondition, this.parameterTypeMap);
}
 
Example #14
Source File: FilterDefinitionFactoryBean.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Class<FilterDefinition> getObjectType() {
	return FilterDefinition.class;
}
 
Example #15
Source File: FilterDefinitionFactoryBean.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void afterPropertiesSet() {
	this.filterDefinition =
			new FilterDefinition(this.filterName, this.defaultFilterCondition, this.parameterTypeMap);
}
 
Example #16
Source File: LocalSessionFactoryBean.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Specify the Hibernate FilterDefinitions to register with the SessionFactory.
 * This is an alternative to specifying <&lt;filter-def&gt; elements in
 * Hibernate mapping files.
 * <p>Typically, the passed-in FilterDefinition objects will have been defined
 * as Spring FilterDefinitionFactoryBeans, probably as inner beans within the
 * LocalSessionFactoryBean definition.
 * @see FilterDefinitionFactoryBean
 * @see org.hibernate.cfg.Configuration#addFilterDefinition
 */
public void setFilterDefinitions(FilterDefinition... filterDefinitions) {
	this.filterDefinitions = filterDefinitions;
}
 
Example #17
Source File: Filter.java    From cacheonix-core with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Get the filter definition containing additional information about the
 * filter (such as default-condition and expected parameter names/types).
 *
 * @return The filter definition
 */
public FilterDefinition getFilterDefinition();
 
Example #18
Source File: LocalSessionFactoryBean.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Specify the Hibernate FilterDefinitions to register with the SessionFactory.
 * This is an alternative to specifying <&lt;filter-def&gt; elements in
 * Hibernate mapping files.
 * <p>Typically, the passed-in FilterDefinition objects will have been defined
 * as Spring FilterDefinitionFactoryBeans, probably as inner beans within the
 * LocalSessionFactoryBean definition.
 * @see FilterDefinitionFactoryBean
 * @see org.hibernate.cfg.Configuration#addFilterDefinition
 */
public void setFilterDefinitions(FilterDefinition... filterDefinitions) {
	this.filterDefinitions = filterDefinitions;
}
 
Example #19
Source File: FilterImpl.java    From cacheonix-core with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Constructs a new FilterImpl.
 *
 * @param configuration The filter's global configuration.
 */
public FilterImpl(FilterDefinition configuration) {
	this.definition = configuration;
	filterName = definition.getFilterName();
}
 
Example #20
Source File: SessionFactory.java    From cacheonix-core with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Obtain the definition of a filter by name.
 *
 * @param filterName The name of the filter for which to obtain the definition.
 * @return The filter definition.
 * @throws HibernateException If no filter defined with the given name.
 */
public FilterDefinition getFilterDefinition(String filterName) throws HibernateException;