HHH-7907 Bind filter

This commit is contained in:
Strong Liu 2013-01-06 22:48:44 +08:00
parent 4a567e04cb
commit 87e19a2c3e
46 changed files with 365 additions and 90 deletions

View File

@ -61,9 +61,7 @@ public int hashCode() {
public boolean equals(Object other) {
if ( !(other instanceof FilterKey) ) return false;
FilterKey that = (FilterKey) other;
if ( !that.filterName.equals(filterName) ) return false;
if ( !that.filterParameters.equals(filterParameters) ) return false;
return true;
return that.filterName.equals( filterName ) && that.filterParameters.equals( filterParameters );
}
public String toString() {

View File

@ -292,7 +292,7 @@ private void addCollectionToCache(LoadingCollectionEntry lce, CollectionPersiste
LOG.debugf( "Caching collection: %s", MessageHelper.collectionInfoString( persister, lce.getCollection(), lce.getKey(), session ) );
}
if ( !session.getEnabledFilters().isEmpty() && persister.isAffectedByEnabledFilters( session ) ) {
if ( !session.getLoadQueryInfluencers().hasEnabledFilters() && persister.isAffectedByEnabledFilters( session ) ) {
// some filters affecting the collection are enabled on the session, so do not do the put into the cache.
LOG.debug( "Refusing to add to cache due to enabled filters" );
// todo : add the notion of enabled filters to the CacheKey to differentiate filtered collections from non-filtered;

View File

@ -34,6 +34,7 @@
import org.jboss.logging.Logger;
import org.hibernate.Filter;
import org.hibernate.MappingException;
import org.hibernate.QueryException;
import org.hibernate.cfg.Environment;
@ -159,7 +160,7 @@ private ParameterMetadata buildParameterMetadata(String query){
return new ParameterMetadata( ordinalDescriptors, namedParamDescriptorMap );
}
public HQLQueryPlan getHQLQueryPlan( String queryString, boolean shallow, Map enabledFilters)
public HQLQueryPlan getHQLQueryPlan( String queryString, boolean shallow, Map<String, Filter> enabledFilters)
throws QueryException, MappingException {
HQLQueryPlanKey key = new HQLQueryPlanKey( queryString, shallow, enabledFilters );
HQLQueryPlan value = (HQLQueryPlan) queryPlanCache.get( key );
@ -216,7 +217,7 @@ private static class HQLQueryPlanKey implements Serializable {
private final Set<DynamicFilterKey> filterKeys;
private final int hashCode;
public HQLQueryPlanKey(String query, boolean shallow, Map enabledFilters) {
public HQLQueryPlanKey(String query, boolean shallow, Map<String, Filter> enabledFilters) {
this.query = query;
this.shallow = shallow;
if ( CollectionHelper.isEmpty( enabledFilters ) ) {
@ -227,7 +228,7 @@ public HQLQueryPlanKey(String query, boolean shallow, Map enabledFilters) {
CollectionHelper.determineProperSizing( enabledFilters ),
CollectionHelper.LOAD_FACTOR
);
for ( Object o : enabledFilters.values() ) {
for ( Filter o : enabledFilters.values() ) {
tmp.add( new DynamicFilterKey( (FilterImpl) o ) );
}
this.filterKeys = Collections.unmodifiableSet( tmp );

View File

@ -33,6 +33,7 @@
import org.jboss.logging.Logger;
import org.hibernate.Filter;
import org.hibernate.HibernateException;
import org.hibernate.LockOptions;
import org.hibernate.QueryException;
@ -463,7 +464,7 @@ public void processFilters(String sql, SessionImplementor session) {
}
@SuppressWarnings( {"unchecked"})
public void processFilters(String sql, Map filters, SessionFactoryImplementor factory) {
public void processFilters(String sql, Map<String, Filter> filters, SessionFactoryImplementor factory) {
if ( filters.size() == 0 || !sql.contains( ParserHelper.HQL_VARIABLE_PREFIX ) ) {
// HELLA IMPORTANT OPTIMIZATION!!!
processedPositionalParameterValues = getPositionalParameterValues();

View File

@ -105,7 +105,7 @@ private boolean initializeCollectionFromCache(
PersistentCollection collection,
SessionImplementor source) {
if ( !source.getLoadQueryInfluencers().getEnabledFilters().isEmpty() && persister.isAffectedByEnabledFilters( source ) ) {
if ( !source.getLoadQueryInfluencers().hasEnabledFilters() && persister.isAffectedByEnabledFilters( source ) ) {
LOG.trace( "Disregarding cached version (if any) of collection due to enabled filters" );
return false;
}

View File

@ -27,6 +27,7 @@
import org.jboss.logging.Logger;
import org.hibernate.Filter;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.hql.spi.FilterTranslator;
import org.hibernate.hql.spi.QueryTranslator;
@ -54,7 +55,7 @@ public ASTQueryTranslatorFactory() {
public QueryTranslator createQueryTranslator(
String queryIdentifier,
String queryString,
Map filters,
Map<String, Filter> filters,
SessionFactoryImplementor factory) {
return new QueryTranslatorImpl( queryIdentifier, queryString, filters, factory );
}
@ -65,7 +66,7 @@ public QueryTranslator createQueryTranslator(
public FilterTranslator createFilterTranslator(
String queryIdentifier,
String queryString,
Map filters,
Map<String, Filter> filters,
SessionFactoryImplementor factory) {
return new QueryTranslatorImpl( queryIdentifier, queryString, filters, factory );
}

View File

@ -36,6 +36,7 @@
import antlr.collections.AST;
import org.jboss.logging.Logger;
import org.hibernate.Filter;
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.QueryException;
@ -87,7 +88,7 @@ public class QueryTranslatorImpl implements FilterTranslator {
private boolean shallowQuery;
private Map tokenReplacements;
private Map enabledFilters; //TODO:this is only needed during compilation .. can we eliminate the instvar?
private Map<String, Filter> enabledFilters; //TODO:this is only needed during compilation .. can we eliminate the instvar?
private boolean compiled;
private QueryLoader queryLoader;
@ -111,7 +112,7 @@ public class QueryTranslatorImpl implements FilterTranslator {
public QueryTranslatorImpl(
String queryIdentifier,
String query,
Map enabledFilters,
Map<String, Filter> enabledFilters,
SessionFactoryImplementor factory) {
this.queryIdentifier = queryIdentifier;
this.hql = query;
@ -444,7 +445,7 @@ public String getQueryString() {
return hql;
}
public Map getEnabledFilters() {
public Map<String, Filter> getEnabledFilters() {
return enabledFilters;
}

View File

@ -25,6 +25,7 @@
package org.hibernate.hql.internal.classic;
import java.util.Map;
import org.hibernate.Filter;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.hql.spi.FilterTranslator;
import org.hibernate.hql.spi.QueryTranslator;
@ -44,7 +45,7 @@ public class ClassicQueryTranslatorFactory implements QueryTranslatorFactory {
public QueryTranslator createQueryTranslator(
String queryIdentifier,
String queryString,
Map filters,
Map<String, Filter> filters,
SessionFactoryImplementor factory) {
return new QueryTranslatorImpl( queryIdentifier, queryString, filters, factory );
}
@ -55,7 +56,7 @@ public QueryTranslator createQueryTranslator(
public FilterTranslator createFilterTranslator(
String queryIdentifier,
String queryString,
Map filters,
Map<String, Filter> filters,
SessionFactoryImplementor factory) {
return new QueryTranslatorImpl( queryIdentifier, queryString, filters, factory );
}

View File

@ -41,6 +41,7 @@
import org.jboss.logging.Logger;
import org.hibernate.Filter;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.LockOptions;
@ -140,7 +141,7 @@ public class QueryTranslatorImpl extends BasicLoader implements FilterTranslator
private String[] suffixes;
private Map enabledFilters;
private Map<String, Filter> enabledFilters;
/**
* Construct a query translator
@ -155,7 +156,7 @@ public class QueryTranslatorImpl extends BasicLoader implements FilterTranslator
public QueryTranslatorImpl(
String queryIdentifier,
String queryString,
Map enabledFilters,
Map<String, Filter> enabledFilters,
SessionFactoryImplementor factory) {
super( factory );
this.queryIdentifier = queryIdentifier;
@ -1163,7 +1164,7 @@ public Class getHolderClass() {
return holderClass;
}
public Map getEnabledFilters() {
public Map<String, Filter> getEnabledFilters() {
return enabledFilters;
}

View File

@ -28,6 +28,7 @@
import java.util.Map;
import java.util.Set;
import org.hibernate.Filter;
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.QueryException;
@ -141,7 +142,7 @@ int executeUpdate(QueryParameters queryParameters, SessionImplementor session)
*
* @return Filters enabled for this query execution.
*/
Map getEnabledFilters();
Map<String, Filter> getEnabledFilters();
/**
* Returns an array of Types represented in the query result.

View File

@ -25,6 +25,7 @@
package org.hibernate.hql.spi;
import java.util.Map;
import org.hibernate.Filter;
import org.hibernate.engine.spi.SessionFactoryImplementor;
/**
@ -47,7 +48,7 @@ public interface QueryTranslatorFactory {
* @param factory The session factory.
* @return an appropriate translator.
*/
public QueryTranslator createQueryTranslator(String queryIdentifier, String queryString, Map filters, SessionFactoryImplementor factory);
public QueryTranslator createQueryTranslator(String queryIdentifier, String queryString, Map<String, Filter> filters, SessionFactoryImplementor factory);
/**
* Construct a {@link FilterTranslator} instance capable of translating
@ -55,5 +56,5 @@ public interface QueryTranslatorFactory {
*
* @see #createQueryTranslator
*/
public FilterTranslator createFilterTranslator(String queryIdentifier, String queryString, Map filters, SessionFactoryImplementor factory);
public FilterTranslator createFilterTranslator(String queryIdentifier, String queryString, Map<String, Filter> filters, SessionFactoryImplementor factory);
}

View File

@ -266,7 +266,7 @@ public StoredProcedureCall createStoredProcedureCall(String procedureName, Strin
}
protected HQLQueryPlan getHQLQueryPlan(String query, boolean shallow) throws HibernateException {
return factory.getQueryPlanCache().getHQLQueryPlan( query, shallow, getEnabledFilters() );
return factory.getQueryPlanCache().getHQLQueryPlan( query, shallow, getLoadQueryInfluencers().getEnabledFilters() );
}
protected NativeSQLQueryPlan getNativeSQLQueryPlan(NativeSQLQuerySpecification spec) throws HibernateException {

View File

@ -29,6 +29,7 @@
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.persister.entity.Joinable;
/**
@ -43,6 +44,7 @@ public class FilterConfiguration {
private final Map<String, String> aliasTableMap;
private final Map<String, String> aliasEntityMap;
private final PersistentClass persistentClass;
private final EntityBinding entityBinding;
public FilterConfiguration(
String name,
String condition,
@ -56,6 +58,23 @@ public FilterConfiguration(
this.aliasTableMap = aliasTableMap;
this.aliasEntityMap = aliasEntityMap;
this.persistentClass = persistentClass;
this.entityBinding = null;
}
public FilterConfiguration(
String name,
String condition,
boolean autoAliasInjection,
Map<String, String> aliasTableMap,
Map<String, String> aliasEntityMap,
EntityBinding entityBinding) {
this.name = name;
this.condition = condition;
this.autoAliasInjection = autoAliasInjection;
this.aliasTableMap = aliasTableMap;
this.aliasEntityMap = aliasEntityMap;
this.persistentClass = null;
this.entityBinding = entityBinding;
}
public String getName() {
@ -83,6 +102,10 @@ else if ( persistentClass != null ) {
);
return Collections.singletonMap( null, table );
}
else if ( entityBinding != null ) {
String table = entityBinding.getPrimaryTable().getQualifiedName( factory.getDialect() );
return Collections.singletonMap( null, table );
}
else {
return Collections.emptyMap();
}

View File

@ -27,9 +27,12 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.hibernate.Filter;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.sql.Template;
/**
@ -51,21 +54,20 @@ public class FilterHelper {
* conditions are the values.
*
* @param filters The map of defined filters.
* @param dialect The sql dialect
* @param factory The session factory
*/
public FilterHelper(List filters, SessionFactoryImplementor factory) {
int filterCount = filters.size();
filterNames = new String[filterCount];
filterConditions = new String[filterCount];
filterAutoAliasFlags = new boolean[filterCount];
filterAliasTableMaps = new Map[filterCount];
Iterator iter = filters.iterator();
filterCount = 0;
public FilterHelper(List<FilterConfiguration> filters, SessionFactoryImplementor factory) {
int size = filters.size();
filterNames = new String[size];
filterConditions = new String[size];
filterAutoAliasFlags = new boolean[size];
filterAliasTableMaps = new Map[size];
Iterator<FilterConfiguration> iter = filters.iterator();
int filterCount = 0;
while ( iter.hasNext() ) {
filterAutoAliasFlags[filterCount] = false;
final FilterConfiguration filter = (FilterConfiguration) iter.next();
filterNames[filterCount] = (String) filter.getName();
final FilterConfiguration filter = iter.next();
filterNames[filterCount] = filter.getName();
filterConditions[filterCount] = filter.getCondition();
filterAliasTableMaps[filterCount] = filter.getAliasTableMap(factory);
if ((filterAliasTableMaps[filterCount].isEmpty() || isTableFromPersistentClass(filterAliasTableMaps[filterCount])) && filter.useAutoAliasInjection()){
@ -90,23 +92,23 @@ private static boolean isTableFromPersistentClass(Map<String,String> aliasTableM
return aliasTableMap.size() == 1 && aliasTableMap.containsKey(null);
}
public boolean isAffectedBy(Map enabledFilters) {
for ( int i = 0, max = filterNames.length; i < max; i++ ) {
if ( enabledFilters.containsKey( filterNames[i] ) ) {
public boolean isAffectedBy(Set<String> enabledFilters) {
for ( String filterName : filterNames ) {
if ( enabledFilters.contains( filterName ) ) {
return true;
}
}
return false;
}
public String render(FilterAliasGenerator aliasGenerator, Map enabledFilters) {
public String render(FilterAliasGenerator aliasGenerator, Map<String, Filter> enabledFilters) {
StringBuilder buffer = new StringBuilder();
render( buffer, aliasGenerator, enabledFilters );
return buffer.toString();
}
public void render(StringBuilder buffer, FilterAliasGenerator aliasGenerator, Map enabledFilters) {
if ( filterNames != null && filterNames.length > 0 ) {
public void render(StringBuilder buffer, FilterAliasGenerator aliasGenerator, Map<String, Filter> enabledFilters) {
if ( CollectionHelper.isNotEmpty( filterNames ) ) {
for ( int i = 0, max = filterNames.length; i < max; i++ ) {
if ( enabledFilters.containsKey( filterNames[i] ) ) {
final String condition = filterConditions[i];

View File

@ -1482,12 +1482,12 @@ private FilterQueryPlan getFilterQueryPlan(
if ( roleAfterFlush == null ) {
throw new QueryException( "The collection was unreferenced" );
}
plan = factory.getQueryPlanCache().getFilterQueryPlan( filter, roleAfterFlush.getRole(), shallow, getEnabledFilters() );
plan = factory.getQueryPlanCache().getFilterQueryPlan( filter, roleAfterFlush.getRole(), shallow, getLoadQueryInfluencers().getEnabledFilters() );
}
else {
// otherwise, we only need to flush if there are in-memory changes
// to the queried tables
plan = factory.getQueryPlanCache().getFilterQueryPlan( filter, roleBeforeFlush.getRole(), shallow, getEnabledFilters() );
plan = factory.getQueryPlanCache().getFilterQueryPlan( filter, roleBeforeFlush.getRole(), shallow, getLoadQueryInfluencers().getEnabledFilters() );
if ( autoFlushIfRequired( plan.getQuerySpaces() ) ) {
// might need to run a different filter entirely after the flush
// because the collection role may have changed
@ -1497,7 +1497,7 @@ private FilterQueryPlan getFilterQueryPlan(
if ( roleAfterFlush == null ) {
throw new QueryException( "The collection was dereferenced" );
}
plan = factory.getQueryPlanCache().getFilterQueryPlan( filter, roleAfterFlush.getRole(), shallow, getEnabledFilters() );
plan = factory.getQueryPlanCache().getFilterQueryPlan( filter, roleAfterFlush.getRole(), shallow, getLoadQueryInfluencers().getEnabledFilters() );
}
}
}

View File

@ -135,6 +135,10 @@ public static boolean isEmpty(Collection collection) {
return collection == null || collection.isEmpty();
}
public static boolean isEmpty(Iterable iterable){
return iterable == null || !iterable.iterator().hasNext();
}
public static boolean isEmpty(Map map) {
return map == null || map.isEmpty();
}

View File

@ -26,6 +26,7 @@
import java.util.List;
import java.util.Map;
import org.hibernate.Filter;
import org.hibernate.MappingException;
import org.hibernate.engine.internal.JoinHelper;
import org.hibernate.engine.spi.SessionFactoryImplementor;
@ -52,7 +53,7 @@ public final class OuterJoinableAssociation {
private final String[] rhsColumns;
private final JoinType joinType;
private final String on;
private final Map enabledFilters;
private final Map<String, Filter> enabledFilters;
private final boolean hasRestriction;
public static OuterJoinableAssociation createRoot(
@ -83,7 +84,7 @@ public OuterJoinableAssociation(
String withClause,
boolean hasRestriction,
SessionFactoryImplementor factory,
Map enabledFilters) throws MappingException {
Map<String, Filter> enabledFilters) throws MappingException {
this.propertyPath = propertyPath;
this.joinableType = joinableType;
this.lhsAlias = lhsAlias;

View File

@ -54,6 +54,7 @@
import org.hibernate.id.PersistentIdentifierGenerator;
import org.hibernate.id.factory.IdentifierGeneratorFactory;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.FilterConfiguration;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.ValueHolder;
@ -121,6 +122,7 @@
import org.hibernate.metamodel.spi.source.DiscriminatorSource;
import org.hibernate.metamodel.spi.source.EntityHierarchy;
import org.hibernate.metamodel.spi.source.EntitySource;
import org.hibernate.metamodel.spi.source.FilterSource;
import org.hibernate.metamodel.spi.source.ForeignKeyContributingSource;
import org.hibernate.metamodel.spi.source.ForeignKeyContributingSource.JoinColumnResolutionContext;
import org.hibernate.metamodel.spi.source.ForeignKeyContributingSource.JoinColumnResolutionDelegate;
@ -383,6 +385,19 @@ private EntityBinding createEntityBinding(
entityBinding.addSynchronizedTableNames( entitySource.getSynchronizedTableNames() );
}
resolveEntityLaziness( entityBinding, entitySource );
if ( entitySource.getFilterSources() != null ) {
for ( FilterSource filterSource : entitySource.getFilterSources() ) {
FilterConfiguration filterConfiguration = new FilterConfiguration(
filterSource.getName(),
filterSource.getCondition(),
filterSource.shouldAutoInjectAliases(),
filterSource.getAliasToTableMap(),
filterSource.getAliasToEntityMap(),
entityBinding
);
entityBinding.addFilterConfiguration( filterConfiguration );
}
}
// Register binding with metadata
metadata.addEntity( entityBinding );
return entityBinding;
@ -1337,6 +1352,20 @@ private AbstractPluralAttributeBinding bindPluralAttribute(
// (ex: Set vs. SortedSet).
bindSortingAndOrdering( attributeBinding, attributeSource );
if ( attributeSource.getFilterSources() != null ) {
for ( final FilterSource filterSource : attributeSource.getFilterSources() ) {
FilterConfiguration filterConfiguration = new FilterConfiguration(
filterSource.getName(),
filterSource.getCondition(),
filterSource.shouldAutoInjectAliases(),
filterSource.getAliasToTableMap(),
filterSource.getAliasToEntityMap(),
attributeBindingContainer.seekEntityBinding()
);
attributeBinding.addFilterConfiguration( filterConfiguration );
}
}
final Type resolvedType = typeHelper.resolvePluralType( attributeBinding, attributeSource, nature );
final HibernateTypeDescriptor hibernateTypeDescriptor = attributeBinding.getHibernateTypeDescriptor();
ReflectedCollectionJavaTypes reflectedCollectionJavaTypes = HibernateTypeHelper.getReflectedCollectionJavaTypes(

View File

@ -48,6 +48,7 @@
import org.hibernate.id.factory.spi.MutableIdentifierGeneratorFactory;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.ValueHolder;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.jaxb.spi.JaxbRoot;
import org.hibernate.metamodel.MetadataSourceProcessingOrder;
import org.hibernate.metamodel.MetadataSources;
@ -77,6 +78,7 @@
import org.hibernate.metamodel.spi.relational.Column;
import org.hibernate.metamodel.spi.relational.Database;
import org.hibernate.metamodel.spi.source.FilterDefinitionSource;
import org.hibernate.metamodel.spi.source.FilterParameterSource;
import org.hibernate.metamodel.spi.source.IdentifierGeneratorSource;
import org.hibernate.metamodel.spi.source.MappingDefaults;
import org.hibernate.metamodel.spi.source.MetaAttributeContext;
@ -290,13 +292,27 @@ private void processFilterDefinitions(MetadataSourceProcessor[] metadataSourcePr
new FilterDefinition(
filterDefinitionSource.getName(),
filterDefinitionSource.getCondition(),
null // the params, todo : need to figure out how to handle the type portion
resolveFilterDefinitionParamType(filterDefinitionSource.getParameterSources())
)
);
}
}
}
private Map<String, org.hibernate.type.Type> resolveFilterDefinitionParamType(Iterable<FilterParameterSource> filterParameterSources){
if( CollectionHelper.isEmpty( filterParameterSources )){
return null;
}
Map<String, org.hibernate.type.Type> params = new HashMap<String, org.hibernate.type.Type>( );
for(final FilterParameterSource parameterSource : filterParameterSources){
final String name = parameterSource.getParameterName();
final String typeName = parameterSource.getParameterValueTypeName();
final org.hibernate.type.Type type = getTypeResolver().heuristicType( typeName );
params.put( name, type );
}
return params;
}
@Override
public void addFilterDefinition(FilterDefinition filterDefinition) {
if ( filterDefinition == null || filterDefinition.getFilterName() == null ) {

View File

@ -46,6 +46,7 @@
import org.hibernate.metamodel.spi.source.AttributeSource;
import org.hibernate.metamodel.spi.source.ConstraintSource;
import org.hibernate.metamodel.spi.source.EntitySource;
import org.hibernate.metamodel.spi.source.FilterSource;
import org.hibernate.metamodel.spi.source.JpaCallbackSource;
import org.hibernate.metamodel.spi.source.LocalBindingContext;
import org.hibernate.metamodel.spi.source.MetaAttributeSource;
@ -55,6 +56,7 @@
import org.hibernate.metamodel.spi.source.TableSpecificationSource;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationValue;
import org.jboss.jandex.ClassInfo;
/**
* @author Hardy Ferentschik
@ -63,6 +65,7 @@ public class EntitySourceImpl implements EntitySource {
private final EntityClass entityClass;
private final Set<SubclassEntitySource> subclassEntitySources;
private final String jpaEntityName;
private final FilterSource[] filterSources;
public EntitySourceImpl(EntityClass entityClass) {
this.entityClass = entityClass;
@ -76,6 +79,39 @@ public EntitySourceImpl(EntityClass entityClass) {
}
addImports();
this.filterSources = buildFilterSources();
}
private FilterSource[] buildFilterSources() {
AnnotationInstance filtersAnnotation = JandexHelper.getSingleAnnotation(
entityClass.getClassInfo(),
HibernateDotNames.FILTERS ,
ClassInfo.class
);
List<FilterSource> filterSourceList = new ArrayList<FilterSource>();
if ( filtersAnnotation != null ) {
AnnotationInstance[] annotationInstances = filtersAnnotation.value().asNestedArray();
for ( AnnotationInstance filterAnnotation : annotationInstances ) {
FilterSource filterSource = new FilterSourceImpl( filterAnnotation );
filterSourceList.add( filterSource );
}
}
AnnotationInstance filterAnnotation = JandexHelper.getSingleAnnotation(
entityClass.getClassInfo(),
HibernateDotNames.FILTER ,
ClassInfo.class
);
if ( filterAnnotation != null ) {
FilterSource filterSource = new FilterSourceImpl( filterAnnotation );
filterSourceList.add( filterSource );
}
if ( filterSourceList.isEmpty() ) {
return null;
}
else {
return filterSourceList.toArray( new FilterSource[filterSourceList.size()] );
}
}
public EntityClass getEntityClass() {
@ -233,6 +269,11 @@ public void add(SubclassEntitySource subclassEntitySource) {
subclassEntitySources.add( subclassEntitySource );
}
@Override
public FilterSource[] getFilterSources() {
return filterSources;
}
@Override
public Iterable<SubclassEntitySource> subclassEntitySources() {
return subclassEntitySources;

View File

@ -84,7 +84,7 @@ public String getParameterName() {
}
@Override
public String getParameterValueTyeName() {
public String getParameterValueTypeName() {
return type;
}
}

View File

@ -45,7 +45,7 @@ public class FilterSourceImpl implements FilterSource {
public FilterSourceImpl(AnnotationInstance filterAnnotation) {
this.name = JandexHelper.getValue( filterAnnotation, "name", String.class );
this.condition = JandexHelper.getValue( filterAnnotation, "condition", String.class );
this.autoAliasInjection = JandexHelper.getValue( filterAnnotation, "deduceAliasInjectionPoints", boolean.class );
this.autoAliasInjection = JandexHelper.getValue( filterAnnotation, "deduceAliasInjectionPoints", Boolean.class );
for ( AnnotationInstance aliasAnnotation : JandexHelper.getValue( filterAnnotation, "aliases", AnnotationInstance[].class ) ) {
final String alias = JandexHelper.getValue( aliasAnnotation, "alias", String.class );

View File

@ -23,7 +23,9 @@
*/
package org.hibernate.metamodel.internal.source.annotations;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.jboss.jandex.AnnotationInstance;
@ -34,9 +36,12 @@
import org.hibernate.metamodel.internal.source.annotations.attribute.PluralAssociationAttribute;
import org.hibernate.metamodel.internal.source.annotations.entity.ConfiguredClass;
import org.hibernate.metamodel.internal.source.annotations.entity.EntityClass;
import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.spi.binding.Caching;
import org.hibernate.metamodel.spi.binding.CustomSQL;
import org.hibernate.metamodel.spi.source.ExplicitHibernateTypeSource;
import org.hibernate.metamodel.spi.source.FilterSource;
import org.hibernate.metamodel.spi.source.MetaAttributeSource;
import org.hibernate.metamodel.spi.source.Orderable;
import org.hibernate.metamodel.spi.source.PluralAttributeElementSource;
@ -55,7 +60,7 @@ public class PluralAttributeSourceImpl implements PluralAttributeSource, Orderab
private final ExplicitHibernateTypeSource typeSource;
private final PluralAttributeKeySource keySource;
private final PluralAttributeElementSource elementSource;
private final FilterSource[] filterSources;
public PluralAttributeSourceImpl(
final PluralAssociationAttribute associationAttribute,
final ConfiguredClass entityClass ) {
@ -64,6 +69,37 @@ public PluralAttributeSourceImpl(
this.typeSource = new ExplicitHibernateTypeSourceImpl( associationAttribute );
this.nature = associationAttribute.getPluralAttributeNature();
this.elementSource = determineElementSource( associationAttribute, entityClass );
this.filterSources = determineFilterSources(associationAttribute);
}
private FilterSource[] determineFilterSources(PluralAssociationAttribute associationAttribute) {
AnnotationInstance filtersAnnotation = JandexHelper.getSingleAnnotation(
associationAttribute.annotations(),
HibernateDotNames.FILTERS
);
List<FilterSource> filterSourceList = new ArrayList<FilterSource>();
if ( filtersAnnotation != null ) {
AnnotationInstance[] annotationInstances = filtersAnnotation.value().asNestedArray();
for ( AnnotationInstance filterAnnotation : annotationInstances ) {
FilterSource filterSource = new FilterSourceImpl( filterAnnotation );
filterSourceList.add( filterSource );
}
}
AnnotationInstance filterAnnotation = JandexHelper.getSingleAnnotation(
associationAttribute.annotations(),
HibernateDotNames.FILTER
);
if ( filterAnnotation != null ) {
FilterSource filterSource = new FilterSourceImpl( filterAnnotation );
filterSourceList.add( filterSource );
}
if ( filterSourceList.isEmpty() ) {
return null;
}
else {
return filterSourceList.toArray( new FilterSource[filterSourceList.size()] );
}
}
@Override
@ -76,6 +112,11 @@ public PluralAttributeElementSource getElementSource() {
return elementSource;
}
@Override
public FilterSource[] getFilterSources() {
return filterSources;
}
@Override
public ValueHolder<Class<?>> getElementClassReference() {
// needed for arrays

View File

@ -48,6 +48,7 @@
import org.hibernate.metamodel.spi.source.AggregatedCompositeIdentifierSource;
import org.hibernate.metamodel.spi.source.ComponentAttributeSource;
import org.hibernate.metamodel.spi.source.DiscriminatorSource;
import org.hibernate.metamodel.spi.source.FilterSource;
import org.hibernate.metamodel.spi.source.IdentifierSource;
import org.hibernate.metamodel.spi.source.MetaAttributeSource;
import org.hibernate.metamodel.spi.source.MultiTenancySource;

View File

@ -201,12 +201,7 @@ public EntityBindingContext getLocalBindingContext() {
public boolean hostsAnnotation(DotName annotationName) {
List<AnnotationInstance> annotationList = classInfo.annotations().get( annotationName );
if ( annotationList == null ) {
return false;
}
else {
return annotationList.size() > 0;
}
return CollectionHelper.isNotEmpty( annotationList );
}
public Collection<BasicAttribute> getSimpleAttributes() {

View File

@ -448,7 +448,6 @@ private static <T> T explicitAnnotationParameter(AnnotationValue annotationValue
}
returnValue = arr;
}
return type.cast( nullIfUndefined( returnValue, type ) );
}

View File

@ -38,8 +38,10 @@
import org.hibernate.jaxb.spi.hbm.JaxbAnyElement;
import org.hibernate.jaxb.spi.hbm.JaxbArrayElement;
import org.hibernate.jaxb.spi.hbm.JaxbBagElement;
import org.hibernate.jaxb.spi.hbm.JaxbClassElement;
import org.hibernate.jaxb.spi.hbm.JaxbComponentElement;
import org.hibernate.jaxb.spi.hbm.JaxbDynamicComponentElement;
import org.hibernate.jaxb.spi.hbm.JaxbFilterElement;
import org.hibernate.jaxb.spi.hbm.JaxbIdbagElement;
import org.hibernate.jaxb.spi.hbm.JaxbJoinElement;
import org.hibernate.jaxb.spi.hbm.JaxbListElement;
@ -55,6 +57,7 @@
import org.hibernate.metamodel.spi.source.AttributeSource;
import org.hibernate.metamodel.spi.source.ConstraintSource;
import org.hibernate.metamodel.spi.source.EntitySource;
import org.hibernate.metamodel.spi.source.FilterSource;
import org.hibernate.metamodel.spi.source.JpaCallbackSource;
import org.hibernate.metamodel.spi.source.LocalBindingContext;
import org.hibernate.metamodel.spi.source.MetaAttributeSource;
@ -82,7 +85,7 @@ public abstract class AbstractEntitySourceImpl
// logically final, but built during 'afterInstantiation' callback
private List<AttributeSource> attributeSources;
private Set<SecondaryTableSource> secondaryTableSources;
private final FilterSource[] filterSources;
protected AbstractEntitySourceImpl(MappingDocument sourceMappingDocument, EntityElement entityElement) {
super( sourceMappingDocument );
this.entityElement = entityElement;
@ -96,6 +99,34 @@ protected AbstractEntitySourceImpl(MappingDocument sourceMappingDocument, Entity
this.entityName = className;
this.jpaEntityName = StringHelper.unqualify( className );
}
this.filterSources = buildFilterSources();
}
private FilterSource[] buildFilterSources() {
//todo for now, i think all EntityElement should support this.
if ( JaxbClassElement.class.isInstance( entityElement() ) ) {
JaxbClassElement jaxbClassElement = JaxbClassElement.class.cast( entityElement() );
final int size = jaxbClassElement.getFilter().size();
if ( size == 0 ) {
return null;
}
FilterSource[] results = new FilterSource[size];
for ( int i = 0; i < size; i++ ) {
JaxbFilterElement element = jaxbClassElement.getFilter().get( i );
results[i] = new FilterSourceImpl( sourceMappingDocument(), element );
}
return results;
}
else {
return null;
}
}
@Override
public FilterSource[] getFilterSources() {
return filterSources;
}
@Override

View File

@ -31,11 +31,14 @@
import org.hibernate.engine.FetchTiming;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.ValueHolder;
import org.hibernate.jaxb.spi.hbm.JaxbClassElement;
import org.hibernate.jaxb.spi.hbm.JaxbFilterElement;
import org.hibernate.jaxb.spi.hbm.PluralAttributeElement;
import org.hibernate.metamodel.spi.binding.Caching;
import org.hibernate.metamodel.spi.binding.CustomSQL;
import org.hibernate.metamodel.spi.source.AttributeSourceContainer;
import org.hibernate.metamodel.spi.source.ExplicitHibernateTypeSource;
import org.hibernate.metamodel.spi.source.FilterSource;
import org.hibernate.metamodel.spi.source.MappingException;
import org.hibernate.metamodel.spi.source.MetaAttributeSource;
import org.hibernate.metamodel.spi.source.PluralAttributeElementSource;
@ -58,7 +61,7 @@ public abstract class AbstractPluralAttributeSourceImpl
private final PluralAttributeKeySource keySource;
private final PluralAttributeElementSource elementSource;
private final Caching caching;
private final FilterSource[] filterSources;
private ValueHolder<Class<?>> elementClassReference;
protected AbstractPluralAttributeSourceImpl(
@ -92,6 +95,22 @@ public Map<String, String> getParameters() {
return Collections.emptyMap();
}
};
this.filterSources = buildFilterSources();
}
private FilterSource[] buildFilterSources() {
final int size = pluralAttributeElement.getFilter().size();
if ( size == 0 ) {
return null;
}
FilterSource[] results = new FilterSource[size];
for ( int i = 0; i < size; i++ ) {
JaxbFilterElement element = pluralAttributeElement.getFilter().get( i );
results[i] = new FilterSourceImpl( sourceMappingDocument(), element );
}
return results;
}
private PluralAttributeElementSource interpretElementType() {
@ -152,6 +171,11 @@ protected AttributeSourceContainer container() {
return container;
}
@Override
public FilterSource[] getFilterSources() {
return filterSources;
}
@Override
public PluralAttributeKeySource getKeySource() {
return keySource;

View File

@ -36,6 +36,7 @@
import org.hibernate.jaxb.spi.hbm.JaxbClassElement;
import org.hibernate.jaxb.spi.hbm.JaxbCompositeIdElement;
import org.hibernate.jaxb.spi.hbm.JaxbDiscriminatorElement;
import org.hibernate.jaxb.spi.hbm.JaxbFilterElement;
import org.hibernate.jaxb.spi.hbm.JaxbKeyManyToOneElement;
import org.hibernate.jaxb.spi.hbm.JaxbKeyPropertyElement;
import org.hibernate.jaxb.spi.hbm.JaxbMultiTenancyElement;
@ -49,6 +50,7 @@
import org.hibernate.metamodel.spi.source.AttributeSource;
import org.hibernate.metamodel.spi.source.ComponentAttributeSource;
import org.hibernate.metamodel.spi.source.DiscriminatorSource;
import org.hibernate.metamodel.spi.source.FilterSource;
import org.hibernate.metamodel.spi.source.IdentifierSource;
import org.hibernate.metamodel.spi.source.MappingException;
import org.hibernate.metamodel.spi.source.MetaAttributeSource;
@ -84,6 +86,8 @@ protected RootEntitySourceImpl(
afterInstantiation();
}
@Override
protected JaxbClassElement entityElement() {
return (JaxbClassElement) super.entityElement();

View File

@ -291,11 +291,12 @@ public void setComparator( Comparator< ? > comparator ) {
this.comparator = comparator;
}
@Override
public void addFilterConfiguration(FilterConfiguration filterConfiguration) {
filterConfigurations.add( filterConfiguration );
}
@Override
@Override
public List<FilterConfiguration> getFilterConfigurations() {
return filterConfigurations;
}

View File

@ -36,6 +36,7 @@
import org.hibernate.EntityMode;
import org.hibernate.MappingException;
import org.hibernate.engine.spi.FilterDefinition;
import org.hibernate.internal.FilterConfiguration;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.ValueHolder;
import org.hibernate.internal.util.collections.ArrayHelper;
@ -60,7 +61,7 @@
* @author Hardy Ferentschik
* @author Gail Badner
*/
public class EntityBinding extends AbstractAttributeBindingContainer {
public class EntityBinding extends AbstractAttributeBindingContainer implements Filterable {
private static final String NULL_DISCRIMINATOR_MATCH_VALUE = "null";
private static final String NOT_NULL_DISCRIMINATOR_MATCH_VALUE = "not null";
@ -83,7 +84,7 @@ public class EntityBinding extends AbstractAttributeBindingContainer {
private String discriminatorMatchValue;
private Set<FilterDefinition> filterDefinitions = new HashSet<FilterDefinition>();
private List<FilterConfiguration> filterConfigurations = new ArrayList<FilterConfiguration>();
private MetaAttributeContext metaAttributeContext;
@ -412,12 +413,19 @@ public void setDiscriminatorMatchValue(String discriminatorMatchValue) {
this.discriminatorMatchValue = discriminatorMatchValue;
}
public Iterable<FilterDefinition> getFilterDefinitions() {
return filterDefinitions;
@Override
public void addFilterConfiguration(FilterConfiguration filterConfiguration) {
filterConfigurations.add( filterConfiguration );
}
public void addFilterDefinition(FilterDefinition filterDefinition) {
filterDefinitions.add( filterDefinition );
@Override
public List<FilterConfiguration> getFilterConfigurations() {
if ( superEntityBinding != null ) {
List<FilterConfiguration> results = new ArrayList<FilterConfiguration>( filterConfigurations );
results.addAll( superEntityBinding.getFilterConfigurations() );
return results;
}
return filterConfigurations;
}
@Override

View File

@ -0,0 +1,37 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.spi.binding;
import java.util.List;
import org.hibernate.internal.FilterConfiguration;
/**
* @author Strong Liu <stliu@hibernate.org>
*/
public interface Filterable {
public void addFilterConfiguration(FilterConfiguration filterConfiguration);
public List<FilterConfiguration> getFilterConfigurations();
}

View File

@ -35,7 +35,7 @@
*
* @author Steve Ebersole
*/
public interface PluralAttributeBinding extends AttributeBinding, Fetchable {
public interface PluralAttributeBinding extends AttributeBinding, Fetchable, Filterable {
/**
* Retrieve the plural attribute being bound.
*
@ -84,8 +84,6 @@ public interface PluralAttributeBinding extends AttributeBinding, Fetchable {
int getBatchSize();
List<FilterConfiguration> getFilterConfigurations();
String getOrderBy();
String getReferencedPropertyName();

View File

@ -206,4 +206,11 @@ public interface EntitySource extends SubclassEntityContainer, AttributeSourceCo
* {@link EntityListeners entity listeners}) that define JPA callbacks for this entity/mapped superclass.
*/
List<JpaCallbackSource> getJpaCallbackClasses();
/**
* Obtain the filters for this entity.
*
* @return returns an array of the filters for this entity.
*/
public FilterSource[] getFilterSources();
}

View File

@ -41,5 +41,5 @@ public interface FilterParameterSource {
*
* @return the type
*/
public String getParameterValueTyeName();
public String getParameterValueTypeName();
}

View File

@ -43,6 +43,8 @@ public interface PluralAttributeSource
public PluralAttributeElementSource getElementSource();
public FilterSource[] getFilterSources();
public ValueHolder<Class<?>> getElementClassReference();
public TableSpecificationSource getCollectionTableSpecificationSource();

View File

@ -121,4 +121,5 @@ public interface RootEntitySource extends EntitySource {
* @return The natural id caching configuration.
*/
public Caching getNaturalIdCaching();
}

View File

@ -66,6 +66,7 @@
import org.hibernate.id.factory.spi.MutableIdentifierGeneratorFactory;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.FilterAliasGenerator;
import org.hibernate.internal.FilterConfiguration;
import org.hibernate.internal.FilterHelper;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.ArrayHelper;
@ -996,7 +997,7 @@ else if ( !elementType.isEntityType() ) {
//if ( elementBinding.getNature() == Nature.MANY_TO_MANY ) {
//}
//else {
manyToManyFilterHelper = new FilterHelper( Collections.emptyList(), factory );
manyToManyFilterHelper = new FilterHelper( Collections.<FilterConfiguration>emptyList(), factory );
manyToManyWhereString = null;
manyToManyWhereTemplate = null;
hasManyToManyOrder = false;
@ -1054,7 +1055,7 @@ protected CollectionInitializer getAppropriateInitializer(Serializable key, Sess
if ( subselectInitializer != null ) {
return subselectInitializer;
}
else if ( session.getEnabledFilters().isEmpty() ) {
else if ( session.getLoadQueryInfluencers().hasEnabledFilters() ) {
return initializer;
}
else {
@ -2081,8 +2082,8 @@ public CacheEntryStructure getCacheEntryStructure() {
}
public boolean isAffectedByEnabledFilters(SessionImplementor session) {
return filterHelper.isAffectedBy( session.getEnabledFilters() ) ||
( isManyToMany() && manyToManyFilterHelper.isAffectedBy( session.getEnabledFilters() ) );
return filterHelper.isAffectedBy( session.getLoadQueryInfluencers().getEnabledFilterNames() ) ||
( isManyToMany() && manyToManyFilterHelper.isAffectedBy( session.getLoadQueryInfluencers().getEnabledFilterNames() ) );
}
public boolean isSubselectLoadable() {

View File

@ -779,7 +779,7 @@ public AbstractEntityPersister(
iter = definedBySubclass.iterator();
j = 0;
while ( iter.hasNext() ) {
propertyDefinedOnSubclass[j++] = ( ( Boolean ) iter.next() ).booleanValue();
propertyDefinedOnSubclass[j++] = (Boolean) iter.next();
}
// Handle any filters applied to the class level
@ -1174,12 +1174,12 @@ public AbstractEntityPersister(
propertyDefinedOnSubclass = ArrayHelper.toBooleanArray( definedBySubclass );
List<FilterConfiguration> filterDefaultConditions = new ArrayList<FilterConfiguration>();
for ( FilterDefinition filterDefinition : entityBinding.getFilterDefinitions() ) {
filterDefaultConditions.add(new FilterConfiguration(filterDefinition.getFilterName(),
filterDefinition.getDefaultFilterCondition(), true, null, null, null));
}
filterHelper = new FilterHelper( filterDefaultConditions, factory);
// List<FilterConfiguration> filterDefaultConditions = new ArrayList<FilterConfiguration>();
// for ( FilterDefinition filterDefinition : entityBinding.getFilterDefinitions() ) {
// filterDefaultConditions.add(new FilterConfiguration(filterDefinition.getFilterName(),
// filterDefinition.getDefaultFilterCondition(), true, null, null, null));
// }
filterHelper = new FilterHelper( entityBinding.getFilterConfigurations(), factory);
temporaryIdTableName = null;
temporaryIdTableDDL = null;
@ -3909,7 +3909,7 @@ private boolean isAffectedByEnabledFetchProfiles(SessionImplementor session) {
private boolean isAffectedByEnabledFilters(SessionImplementor session) {
return session.getLoadQueryInfluencers().hasEnabledFilters()
&& filterHelper.isAffectedBy( session.getLoadQueryInfluencers().getEnabledFilters() );
&& filterHelper.isAffectedBy( session.getLoadQueryInfluencers().getEnabledFilterNames() );
}
private UniqueEntityLoader getAppropriateLoader(LockOptions lockOptions, SessionImplementor session) {

View File

@ -25,6 +25,7 @@
package org.hibernate.persister.entity;
import java.util.Map;
import org.hibernate.Filter;
import org.hibernate.MappingException;
/**
@ -67,7 +68,7 @@ public interface Joinable {
/**
* Get the where clause filter, given a query alias and considering enabled session filters
*/
public String filterFragment(String alias, Map enabledFilters) throws MappingException;
public String filterFragment(String alias, Map<String, Filter> enabledFilters) throws MappingException;
public String oneToManyFilterFragment(String alias) throws MappingException;
/**

View File

@ -35,6 +35,7 @@
import org.hibernate.EntityMode;
import org.hibernate.FetchMode;
import org.hibernate.Filter;
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.TransientObjectException;
@ -355,7 +356,7 @@ public boolean[] getPropertyNullability() {
return null;
}
public String getOnCondition(String alias, SessionFactoryImplementor factory, Map enabledFilters)
public String getOnCondition(String alias, SessionFactoryImplementor factory, Map<String, Filter> enabledFilters)
throws MappingException {
throw new UnsupportedOperationException();
}

View File

@ -25,6 +25,7 @@
import java.util.Map;
import org.hibernate.Filter;
import org.hibernate.MappingException;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.persister.entity.Joinable;
@ -77,7 +78,7 @@ public interface AssociationType extends Type {
* Get the "filtering" SQL fragment that is applied in the
* SQL on clause, in addition to the usual join condition
*/
public String getOnCondition(String alias, SessionFactoryImplementor factory, Map enabledFilters)
public String getOnCondition(String alias, SessionFactoryImplementor factory, Map<String, Filter> enabledFilters)
throws MappingException;
/**

View File

@ -37,6 +37,7 @@
import java.util.TreeMap;
import org.hibernate.EntityMode;
import org.hibernate.Filter;
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
@ -694,7 +695,7 @@ public String toString() {
return getClass().getName() + '(' + getRole() + ')';
}
public String getOnCondition(String alias, SessionFactoryImplementor factory, Map enabledFilters)
public String getOnCondition(String alias, SessionFactoryImplementor factory, Map<String, Filter> enabledFilters)
throws MappingException {
return getAssociatedJoinable( factory ).filterFragment( alias, enabledFilters );
}

View File

@ -1,9 +1,7 @@
package org.hibernate.test.annotations.filter.subclass.tableperclass;
import org.hibernate.test.annotations.filter.subclass.SubClassTest;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
@FailureExpectedWithNewMetamodel
public class TablePerClassTest extends SubClassTest{
@Override
protected Class[] getAnnotatedClasses() {

View File

@ -8,7 +8,7 @@
* @author Emmanuel Bernard
*/
@Entity
@Table( name = "xPM_Product", uniqueConstraints = {@UniqueConstraint( columnNames = {
@Table( uniqueConstraints = {@UniqueConstraint( columnNames = {
"manufacturerPartNumber", "manufacturerId"} )} )
public class Product extends Component {
}

View File

@ -30,6 +30,7 @@
import java.util.Collections;
import org.hibernate.Filter;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AvailableSettings;
@ -98,7 +99,7 @@ public void releaseSessionFactory() {
public void testImplicitTupleNotEquals() {
final String hql = "from TheEntity e where e.compositeValue <> :p1";
HQLQueryPlan queryPlan = ( (SessionFactoryImplementor) sessionFactory ).getQueryPlanCache()
.getHQLQueryPlan( hql, false, Collections.emptyMap() );
.getHQLQueryPlan( hql, false, Collections.<String, Filter>emptyMap() );
assertEquals( 1, queryPlan.getSqlStrings().length );
System.out.println( " SQL : " + queryPlan.getSqlStrings()[0] );
@ -109,7 +110,7 @@ public void testImplicitTupleNotEquals() {
public void testImplicitTupleNotInList() {
final String hql = "from TheEntity e where e.compositeValue not in (:p1,:p2)";
HQLQueryPlan queryPlan = ( (SessionFactoryImplementor) sessionFactory ).getQueryPlanCache()
.getHQLQueryPlan( hql, false, Collections.emptyMap() );
.getHQLQueryPlan( hql, false, Collections.<String, Filter>emptyMap() );
assertEquals( 1, queryPlan.getSqlStrings().length );
System.out.println( " SQL : " + queryPlan.getSqlStrings()[0] );