Commit 8036b1b1f6fa81ab989c97afb659859c9369c91a
Committed by
Andrew Shvayka
1 parent
80ff6c3b
Improvements
Showing
1 changed file
with
8 additions
and
31 deletions
... | ... | @@ -474,45 +474,22 @@ public class EntityKeyMapping { |
474 | 474 | stringOperationQuery = String.format("%s like :%s) or (%s is null and :%s = '%%')", operationField, paramName, operationField, paramName); |
475 | 475 | break; |
476 | 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 | 481 | break; |
480 | 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 | 487 | break; |
484 | 488 | } |
485 | 489 | ctx.addStringParameter(paramName, value); |
486 | 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 | 493 | private String buildNumericPredicateQuery(QueryContext ctx, String field, NumericFilterPredicate numericFilterPredicate) { |
517 | 494 | String paramName = getNextParameterName(field); |
518 | 495 | ctx.addDoubleParameter(paramName, numericFilterPredicate.getValue().getValue()); | ... | ... |