HHH-7945 xsd element with mixed set to true may return unexpected \n

This commit is contained in:
Strong Liu 2013-01-27 01:26:27 +08:00
parent 046d30ac4d
commit 2fd0d4d241
6 changed files with 15 additions and 7 deletions

View File

@ -29,6 +29,7 @@ import java.util.Map;
import antlr.collections.AST; import antlr.collections.AST;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.hibernate.Filter;
import org.hibernate.hql.internal.antlr.HqlSqlTokenTypes; import org.hibernate.hql.internal.antlr.HqlSqlTokenTypes;
import org.hibernate.hql.internal.ast.HqlSqlWalker; import org.hibernate.hql.internal.ast.HqlSqlWalker;
import org.hibernate.hql.internal.ast.tree.FromElement; import org.hibernate.hql.internal.ast.tree.FromElement;
@ -164,7 +165,7 @@ public class SyntheticAndFactory implements HqlSqlTokenTypes {
public void addDiscriminatorWhereFragment( public void addDiscriminatorWhereFragment(
RestrictableStatement statement, RestrictableStatement statement,
Queryable persister, Queryable persister,
Map enabledFilters, Map<String,Filter> enabledFilters,
String alias) { String alias) {
String whereFragment = persister.filterFragment( alias, enabledFilters ).trim(); String whereFragment = persister.filterFragment( alias, enabledFilters ).trim();
if ( "".equals( whereFragment ) ) { if ( "".equals( whereFragment ) ) {

View File

@ -452,6 +452,10 @@ public final class StringHelper {
return string == null || string.length() == 0; return string == null || string.length() == 0;
} }
public static boolean isEmptyOrWhiteSpace(String string){
return isEmpty( string ) || isEmpty( string.trim() );
}
public static String qualify(String prefix, String name) { public static String qualify(String prefix, String name) {
if ( name == null || prefix == null ) { if ( name == null || prefix == null ) {
throw new NullPointerException(); throw new NullPointerException();

View File

@ -28,6 +28,7 @@ import java.util.List;
import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBElement;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.jaxb.spi.hbm.JaxbFilterDefElement; import org.hibernate.jaxb.spi.hbm.JaxbFilterDefElement;
import org.hibernate.jaxb.spi.hbm.JaxbFilterParamElement; import org.hibernate.jaxb.spi.hbm.JaxbFilterParamElement;
import org.hibernate.metamodel.spi.source.FilterDefinitionSource; import org.hibernate.metamodel.spi.source.FilterDefinitionSource;
@ -55,7 +56,10 @@ public class FilterDefinitionSourceImpl
final List<FilterParameterSource> parameterSources = new ArrayList<FilterParameterSource>(); final List<FilterParameterSource> parameterSources = new ArrayList<FilterParameterSource>();
for ( Object content : filterDefElement.getContent() ) { for ( Object content : filterDefElement.getContent() ) {
if ( String.class.isInstance( content ) ){ if ( String.class.isInstance( content ) ){
conditionContent = (String) content; final String str = content.toString();
if ( !StringHelper.isEmptyOrWhiteSpace( str ) ) {
conditionContent = str.trim();
}
} }
else if ( JAXBElement.class.isInstance( content ) ) { else if ( JAXBElement.class.isInstance( content ) ) {
JAXBElement jaxbElement = JAXBElement.class.cast( content ); JAXBElement jaxbElement = JAXBElement.class.cast( content );

View File

@ -57,7 +57,10 @@ public class FilterSourceImpl
for ( Serializable content : filterElement.getContent() ) { for ( Serializable content : filterElement.getContent() ) {
if ( String.class.isInstance( content ) ) { if ( String.class.isInstance( content ) ) {
conditionContent = String.class.cast( content ); final String str = content.toString();
if ( !StringHelper.isEmptyOrWhiteSpace( str ) ) {
conditionContent = str.trim();
}
} }
else { else {
final JaxbFilterAliasMappingType aliasMapping = JaxbFilterAliasMappingType.class.cast( content ); final JaxbFilterAliasMappingType aliasMapping = JaxbFilterAliasMappingType.class.cast( content );

View File

@ -26,7 +26,6 @@ package org.hibernate.test.filter.hql;
import org.junit.Test; import org.junit.Test;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -36,7 +35,6 @@ import static org.junit.Assert.assertEquals;
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@FailureExpectedWithNewMetamodel
public class BasicFilteredBulkManipulationTest extends BaseCoreFunctionalTestCase { public class BasicFilteredBulkManipulationTest extends BaseCoreFunctionalTestCase {
@Override @Override
public String[] getMappings() { public String[] getMappings() {

View File

@ -29,7 +29,6 @@ import org.hibernate.testing.SkipForDialect;
import org.junit.Test; import org.junit.Test;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -37,7 +36,6 @@ import static org.junit.Assert.assertEquals;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@FailureExpectedWithNewMetamodel
@SkipForDialect( @SkipForDialect(
value = CUBRIDDialect.class, value = CUBRIDDialect.class,
comment = "As of verion 8.4.1 CUBRID doesn't support temporary tables. This test fails with" + comment = "As of verion 8.4.1 CUBRID doesn't support temporary tables. This test fails with" +