Don't add superfluous "and" when there is no discriminator filter
This commit is contained in:
parent
21cca2bbc2
commit
79d2569618
|
@ -30,6 +30,7 @@ import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.internal.DynamicFilterAliasGenerator;
|
import org.hibernate.internal.DynamicFilterAliasGenerator;
|
||||||
import org.hibernate.internal.FilterAliasGenerator;
|
import org.hibernate.internal.FilterAliasGenerator;
|
||||||
import org.hibernate.internal.util.MarkerObject;
|
import org.hibernate.internal.util.MarkerObject;
|
||||||
|
import org.hibernate.internal.util.StringHelper;
|
||||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||||
import org.hibernate.mapping.Column;
|
import org.hibernate.mapping.Column;
|
||||||
|
@ -608,7 +609,11 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
||||||
@Override
|
@Override
|
||||||
protected String filterFragment(String alias, Set<String> treatAsDeclarations) {
|
protected String filterFragment(String alias, Set<String> treatAsDeclarations) {
|
||||||
if ( hasWhere() ) {
|
if ( hasWhere() ) {
|
||||||
return discriminatorFilterFragment( alias, treatAsDeclarations ) + " and " + getSQLWhereString( alias );
|
final String discriminatorFilterFragment = discriminatorFilterFragment( alias, treatAsDeclarations );
|
||||||
|
if ( StringHelper.isNotEmpty( discriminatorFilterFragment ) ) {
|
||||||
|
return discriminatorFilterFragment + " and " + getSQLWhereString( alias );
|
||||||
|
}
|
||||||
|
return getSQLWhereString( alias );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return "";
|
return "";
|
||||||
|
|
Loading…
Reference in New Issue