Commit 8036b1b1f6fa81ab989c97afb659859c9369c91a

Authored by zbeacon
Committed by Andrew Shvayka
1 parent 80ff6c3b

Improvements

@@ -474,45 +474,22 @@ public class EntityKeyMapping { @@ -474,45 +474,22 @@ public class EntityKeyMapping {
474 stringOperationQuery = String.format("%s like :%s) or (%s is null and :%s = '%%')", operationField, paramName, operationField, paramName); 474 stringOperationQuery = String.format("%s like :%s) or (%s is null and :%s = '%%')", operationField, paramName, operationField, paramName);
475 break; 475 break;
476 case CONTAINS: 476 case CONTAINS:
477 - value = "%" + value + "%";  
478 - stringOperationQuery = String.format("%s like :%s) or (%s is null and :%s = '%%%%')", operationField, paramName, operationField, paramName); 477 + if (value.length()>1) {
  478 + value = "%" + value + "%";
  479 + }
  480 + stringOperationQuery = String.format("%s like :%s) or (%s is null and :%s = '')", operationField, paramName, operationField, paramName);
479 break; 481 break;
480 case NOT_CONTAINS: 482 case NOT_CONTAINS:
481 - value = "%" + value + "%";  
482 - stringOperationQuery = String.format("%s not like :%s) or (%s is null and :%s != '%%%%')", operationField, paramName, operationField, paramName); 483 + if (value.length()>1) {
  484 + value = "%" + value + "%";
  485 + }
  486 + stringOperationQuery = String.format("%s not like :%s) or (%s is null and :%s != '')", operationField, paramName, operationField, paramName);
483 break; 487 break;
484 } 488 }
485 ctx.addStringParameter(paramName, value); 489 ctx.addStringParameter(paramName, value);
486 return String.format("((%s is not null and %s)", field, stringOperationQuery); 490 return String.format("((%s is not null and %s)", field, stringOperationQuery);
487 } 491 }
488 492
489 -  
490 -// case EQUAL:  
491 -// stringOperationQuery = String.format("%s = :%s) or (%s is null and :%s = '')", operationField, paramName, operationField, paramName);  
492 -// break;  
493 -// case NOT_EQUAL:  
494 -// stringOperationQuery = String.format("%s != :%s) or (%s is null and :%s != '')", operationField, paramName, operationField, paramName);  
495 -// break;  
496 -// case STARTS_WITH:  
497 -// value += "%";  
498 -// stringOperationQuery = String.format("%s like :%s) or (%s is null and :%s = '')", operationField, paramName, operationField, paramName);  
499 -// break;  
500 -// case ENDS_WITH:  
501 -// value = "%" + value;  
502 -// stringOperationQuery = String.format("%s like :%s) or (%s is null and :%s = '')", operationField, paramName, operationField, paramName);  
503 -// break;  
504 -// case CONTAINS:  
505 -// value = "%" + value + "%";  
506 -// stringOperationQuery = String.format("%s like :%s) or (%s is null and :%s = '')", operationField, paramName, operationField, paramName);  
507 -// break;  
508 -// case NOT_CONTAINS:  
509 -// value = "%" + value + "%";  
510 -// stringOperationQuery = String.format("%s not like :%s) or (%s is null and :%s != '')", operationField, paramName, operationField, paramName);  
511 -// break;  
512 -//}  
513 -// ctx.addStringParameter(paramName, value);  
514 -// return String.format("((%s is not null and %s)", field, stringOperationQuery);  
515 -  
516 private String buildNumericPredicateQuery(QueryContext ctx, String field, NumericFilterPredicate numericFilterPredicate) { 493 private String buildNumericPredicateQuery(QueryContext ctx, String field, NumericFilterPredicate numericFilterPredicate) {
517 String paramName = getNextParameterName(field); 494 String paramName = getNextParameterName(field);
518 ctx.addDoubleParameter(paramName, numericFilterPredicate.getValue().getValue()); 495 ctx.addDoubleParameter(paramName, numericFilterPredicate.getValue().getValue());