Skip to content

Commit

Permalink
HHH-7945 xsd element with mixed set to true may return unexpected \n
Browse files Browse the repository at this point in the history
  • Loading branch information
stliu committed Jan 26, 2013
1 parent 046d30a commit 2fd0d4d
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
Expand Up @@ -29,6 +29,7 @@
import antlr.collections.AST;
import org.jboss.logging.Logger;

import org.hibernate.Filter;
import org.hibernate.hql.internal.antlr.HqlSqlTokenTypes;
import org.hibernate.hql.internal.ast.HqlSqlWalker;
import org.hibernate.hql.internal.ast.tree.FromElement;
Expand Down Expand Up @@ -164,7 +165,7 @@ public void addWhereFragment(
public void addDiscriminatorWhereFragment(
RestrictableStatement statement,
Queryable persister,
Map enabledFilters,
Map<String,Filter> enabledFilters,
String alias) {
String whereFragment = persister.filterFragment( alias, enabledFilters ).trim();
if ( "".equals( whereFragment ) ) {
Expand Down
Expand Up @@ -452,6 +452,10 @@ public static boolean isEmpty(String string) {
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) {
if ( name == null || prefix == null ) {
throw new NullPointerException();
Expand Down
Expand Up @@ -28,6 +28,7 @@

import javax.xml.bind.JAXBElement;

import org.hibernate.internal.util.StringHelper;
import org.hibernate.jaxb.spi.hbm.JaxbFilterDefElement;
import org.hibernate.jaxb.spi.hbm.JaxbFilterParamElement;
import org.hibernate.metamodel.spi.source.FilterDefinitionSource;
Expand Down Expand Up @@ -55,7 +56,10 @@ public FilterDefinitionSourceImpl(
final List<FilterParameterSource> parameterSources = new ArrayList<FilterParameterSource>();
for ( Object content : filterDefElement.getContent() ) {
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 ) ) {
JAXBElement jaxbElement = JAXBElement.class.cast( content );
Expand Down
Expand Up @@ -57,7 +57,10 @@ public FilterSourceImpl(

for ( Serializable content : filterElement.getContent() ) {
if ( String.class.isInstance( content ) ) {
conditionContent = String.class.cast( content );
final String str = content.toString();
if ( !StringHelper.isEmptyOrWhiteSpace( str ) ) {
conditionContent = str.trim();
}
}
else {
final JaxbFilterAliasMappingType aliasMapping = JaxbFilterAliasMappingType.class.cast( content );
Expand Down
Expand Up @@ -26,7 +26,6 @@
import org.junit.Test;

import org.hibernate.Session;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;

import static org.junit.Assert.assertEquals;
Expand All @@ -36,7 +35,6 @@
*
* @author Steve Ebersole
*/
@FailureExpectedWithNewMetamodel
public class BasicFilteredBulkManipulationTest extends BaseCoreFunctionalTestCase {
@Override
public String[] getMappings() {
Expand Down
Expand Up @@ -29,15 +29,13 @@
import org.junit.Test;

import org.hibernate.Session;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;

import static org.junit.Assert.assertEquals;

/**
* @author Steve Ebersole
*/
@FailureExpectedWithNewMetamodel
@SkipForDialect(
value = CUBRIDDialect.class,
comment = "As of verion 8.4.1 CUBRID doesn't support temporary tables. This test fails with" +
Expand Down

0 comments on commit 2fd0d4d

Please sign in to comment.