Пример #1
0
  private static String _jpqlQueryFrom(final EqualsQueryClause<?> eqQry) {
    if (eqQry == null || eqQry.getValue() == null) return null;

    String dbFieldId = eqQry.getFieldId().asString();

    String outJPQL = Strings.of("e._{} = :{}").customizeWith(dbFieldId, dbFieldId).asString();
    return outJPQL;
  }
Пример #2
0
  private static String _jpqlQueryFrom(final RangeQueryClause<?> rangeQry) {
    String dbFieldId = rangeQry.getFieldId().asString();

    String outJPQL = null;
    // TODO mind the bound types... now only CLOSED (inclusive) bounds are being having into account
    if (rangeQry.getRange().hasLowerBound() && rangeQry.getRange().hasUpperBound()) {
      outJPQL =
          Strings.of(
                  "e._{} BETWEEN :{}Start AND :{}End") // SQL between is INCLUSIVE (>= lower and <=
                                                       // lower)
              .customizeWith(dbFieldId, dbFieldId, dbFieldId)
              .asString();
    } else if (rangeQry.getRange().hasLowerBound()) {
      outJPQL = Strings.of("e._{} >= :{}").customizeWith(dbFieldId, dbFieldId).asString();
    } else if (rangeQry.getRange().hasUpperBound()) {
      outJPQL = Strings.of("e._{} <= :{}").customizeWith(dbFieldId, dbFieldId).asString();
    }
    return outJPQL;
  }
Пример #3
0
  private static String _jpqlQueryFrom(final ContainsTextQueryClause containsTextQry) {
    String dbFieldId = containsTextQry.getFieldId().asString();

    String template = null;
    if (containsTextQry.isBegining()) {
      template = "e._{} LIKE '%:{}'";
    } else if (containsTextQry.isEnding()) {
      template = "e._{} LIKE ':{}%'";
    } else if (containsTextQry.isContaining()) {
      template = "e._{} LIKE '%:{}%'";
    } else if (containsTextQry.isFullText()) {
      template = "SQL(  'MATCH({}) " + "AGAINST(? IN BOOLEAN MODE)',':{}')";
    }
    return Strings.of(template).customizeWith(dbFieldId, dbFieldId).asString();
  }
Пример #4
0
 private static String _formatPrimitivesArray(Object primitivesArray) {
   Class<?> elementType = primitivesArray.getClass().getComponentType();
   if (elementType.equals(boolean.class)) return Arrays.toString((boolean[]) primitivesArray);
   if (elementType.equals(char.class)) return Arrays.toString((char[]) primitivesArray);
   if (elementType.equals(byte.class)) return Arrays.toString((byte[]) primitivesArray);
   if (elementType.equals(short.class)) return Arrays.toString((short[]) primitivesArray);
   if (elementType.equals(int.class)) return Arrays.toString((int[]) primitivesArray);
   if (elementType.equals(long.class)) return Arrays.toString((long[]) primitivesArray);
   if (elementType.equals(float.class)) return Arrays.toString((float[]) primitivesArray);
   if (elementType.equals(double.class)) return Arrays.toString((double[]) primitivesArray);
   throw new IllegalArgumentException(
       Strings.of("<")
           .add(primitivesArray.toString())
           .add("> is not an array of primitives")
           .asString());
 }
Пример #5
0
 private static String _jpqlQueryFrom(final ContainedInQueryClause<?> containedInQry) {
   String dbFieldId = containedInQry.getFieldId().asString();
   String outJPQL = Strings.of("e._{} IN :{}").customizeWith(dbFieldId, dbFieldId).asString();
   return outJPQL;
 }