HHH-13496 Empty string processing

This commit is contained in:
Sanne Grinovero 2019-07-05 21:24:46 +01:00
parent 96129e58de
commit 91f4ddb3ec
8 changed files with 12 additions and 11 deletions

View File

@ -32,7 +32,7 @@ public class ImplicitNamingStrategyComponentPathImpl extends ImplicitNamingStrat
if ( attributePath.getParent() != null ) {
process( attributePath.getParent(), sb );
if ( !"".equals( attributePath.getParent().getProperty() ) ) {
sb.append( "_" );
sb.append( '_' );
}
}

View File

@ -542,7 +542,7 @@ public class Ejb3Column {
javax.persistence.Column col = actualCols[index];
final String sqlType;
if ( col.columnDefinition().equals( "" ) ) {
if ( col.columnDefinition().isEmpty() ) {
sqlType = null;
}
else {

View File

@ -144,7 +144,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
for (int i = 0; i < anns.length; i++) {
JoinColumnOrFormula join = anns[i];
JoinFormula formula = join.formula();
if (formula.value() != null && !formula.value().equals("")) {
if ( formula.value() != null && !formula.value().isEmpty() ) {
joinColumns[i] = buildJoinFormula(
formula, mappedBy, joins, propertyHolder, propertyName, buildingContext
);
@ -360,7 +360,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
}
final String sqlType;
if ( columnDefinition.equals( "" ) ) {
if ( columnDefinition.isEmpty() ) {
sqlType = null;
}
else {

View File

@ -67,7 +67,7 @@ public class GroupsPerOperation {
if ( property instanceof String ) {
String stringProperty = (String) property;
String[] groupNames = stringProperty.split( "," );
if ( groupNames.length == 1 && groupNames[0].equals( "" ) ) {
if ( groupNames.length == 1 && groupNames[0].isEmpty() ) {
return EMPTY_GROUPS;
}

View File

@ -66,7 +66,7 @@ public class HibernateTraversableResolver implements TraversableResolver {
addAssociationsToTheSetForAllProperties(
componentType.getPropertyNames(),
componentType.getSubtypes(),
(prefix.equals( "" ) ? name : prefix + name) + ".",
( prefix.isEmpty() ? name : prefix + name) + '.',
factory);
}
}
@ -75,7 +75,7 @@ public class HibernateTraversableResolver implements TraversableResolver {
StringBuilder path = new StringBuilder( );
for ( Path.Node node : pathToTraversableObject ) {
if (node.getName() != null) {
path.append( node.getName() ).append( "." );
path.append( node.getName() ).append( '.' );
}
}
if ( traversableProperty.getName() == null ) {

View File

@ -23,6 +23,7 @@ import org.hibernate.hql.internal.ast.util.ASTUtil;
import org.hibernate.hql.spi.QueryTranslator;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.param.DynamicFilterParameterSpecification;
import org.hibernate.param.ParameterSpecification;
import org.hibernate.persister.collection.QueryableCollection;
@ -445,7 +446,7 @@ public class FromElement extends HqlSqlWalkerNode implements DisplayableNode, Pa
if ( origin == null ) {
return null;
}
if ( origin.getText() == null || "".equals( origin.getText() ) ) {
if ( StringHelper.isEmpty( origin.getText() ) ) {
return origin.getRealOrigin();
}
return origin;
@ -458,7 +459,7 @@ public class FromElement extends HqlSqlWalkerNode implements DisplayableNode, Pa
if ( !origin.isFetch() ) {
return origin;
}
if ( origin.getText() == null || "".equals( origin.getText() ) ) {
if ( StringHelper.isEmpty( origin.getText() ) ) {
return origin.getFetchOrigin();
}
return origin;

View File

@ -158,7 +158,7 @@ public class SyntheticAndFactory implements HqlSqlTokenTypes {
// that this is only used from update and delete HQL statement parsing
whereFragment = StringHelper.replace(
whereFragment,
persister.generateFilterConditionAlias( alias ) + ".",
persister.generateFilterConditionAlias( alias ) + '.',
""
);

View File

@ -490,7 +490,7 @@ public final class StringHelper {
}
public static boolean isEmpty(String string) {
return string == null || string.length() == 0;
return string == null || string.isEmpty();
}
public static boolean isEmptyOrWhiteSpace(String string) {