Пример #1
0
 @Override
 public String toString() {
   return "ForeignKeyKey{"
       + "columns="
       + StringHelper.join(",", columns)
       + ", referencedClassName='"
       + referencedClassName
       + '\''
       + ", referencedColumns="
       + StringHelper.join(",", referencedColumns)
       + '}';
 }
 @SuppressWarnings("unchecked")
 protected void addMappings(Map settings) {
   String[] mappings = getMappings();
   if (mappings != null) {
     settings.put(AvailableSettings.HBXML_FILES, StringHelper.join(",", mappings));
   }
 }
  public static void processDynamicFilterParameters(
      final String sqlFragment, final ParameterContainer container, final HqlSqlWalker walker) {
    if (walker.getEnabledFilters().isEmpty()
        && (!hasDynamicFilterParam(sqlFragment))
        && (!(hasCollectionFilterParam(sqlFragment)))) {
      return;
    }

    Dialect dialect = walker.getSessionFactoryHelper().getFactory().getDialect();
    String symbols =
        new StringBuffer()
            .append(ParserHelper.HQL_SEPARATORS)
            .append(dialect.openQuote())
            .append(dialect.closeQuote())
            .toString();
    StringTokenizer tokens = new StringTokenizer(sqlFragment, symbols, true);
    StringBuffer result = new StringBuffer();

    while (tokens.hasMoreTokens()) {
      final String token = tokens.nextToken();
      if (token.startsWith(ParserHelper.HQL_VARIABLE_PREFIX)) {
        final String filterParameterName = token.substring(1);
        final String[] parts = LoadQueryInfluencers.parseFilterParameterName(filterParameterName);
        final FilterImpl filter = (FilterImpl) walker.getEnabledFilters().get(parts[0]);
        final Object value = filter.getParameter(parts[1]);
        final Type type = filter.getFilterDefinition().getParameterType(parts[1]);
        final String typeBindFragment =
            StringHelper.join(
                ",",
                ArrayHelper.fillArray(
                    "?", type.getColumnSpan(walker.getSessionFactoryHelper().getFactory())));
        final String bindFragment =
            (value != null && Collection.class.isInstance(value))
                ? StringHelper.join(
                    ",", ArrayHelper.fillArray(typeBindFragment, ((Collection) value).size()))
                : typeBindFragment;
        result.append(bindFragment);
        container.addEmbeddedParameter(
            new DynamicFilterParameterSpecification(parts[0], parts[1], type));
      } else {
        result.append(token);
      }
    }

    container.setText(result.toString());
  }
Пример #4
0
  public String toSubselectString(String ukname) {
    String[] joinColumns =
        ukname == null
            ? StringHelper.qualify(alias, loadable.getIdentifierColumnNames())
            : ((PropertyMapping) loadable).toColumns(alias, ukname);

    return "select " + StringHelper.join(", ", joinColumns) + queryString;
  }
  public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
      throws HibernateException {
    String[] columns = criteriaQuery.findColumns(propertyName, criteria);
    String result = StringHelper.join(" and ", StringHelper.suffix(columns, " is null"));
    if (columns.length > 1) result = '(' + result + ')';
    return result;

    // TODO: get SQL rendering out of this package!
  }
 @Override
 protected String toLeftSqlString(Criteria criteria, CriteriaQuery outerQuery) {
   final StringBuilder left = new StringBuilder("(");
   final String[] sqlColumnNames = new String[propertyNames.length];
   for (int i = 0; i < sqlColumnNames.length; ++i) {
     sqlColumnNames[i] = outerQuery.getColumn(criteria, propertyNames[i]);
   }
   left.append(StringHelper.join(", ", sqlColumnNames));
   return left.append(")").toString();
 }
Пример #7
0
 /**
  * The syntax used to add a foreign key constraint to a table.
  *
  * @return String
  */
 public String getAddForeignKeyConstraintString(
     String constraintName,
     String[] foreignKey,
     String referencedTable,
     String[] primaryKey,
     boolean referencesPrimaryKey) {
   // The syntax used to add a foreign key constraint to a table.
   return new StringBuffer(300)
       .append(" ADD CONSTRAINT ")
       .append(constraintName)
       .append(" FOREIGN KEY ")
       .append(constraintName)
       .append(" (")
       .append(StringHelper.join(", ", foreignKey)) // identifier-commalist
       .append(") REFERENCES ")
       .append(referencedTable)
       .append(" (")
       .append(StringHelper.join(", ", primaryKey)) // identifier-commalist
       .append(") ")
       .toString();
 }
Пример #8
0
 @Override
 @SuppressWarnings("StringBufferReplaceableByString")
 public String getAddForeignKeyConstraintString(
     String constraintName,
     String[] foreignKey,
     String referencedTable,
     String[] primaryKey,
     boolean referencesPrimaryKey) {
   // The syntax used to add a foreign key constraint to a table.
   return new StringBuilder(300)
       .append(" ADD CONSTRAINT ")
       .append(constraintName)
       .append(" FOREIGN KEY ")
       .append(constraintName)
       .append(" (")
       .append(StringHelper.join(", ", foreignKey))
       .append(") REFERENCES ")
       .append(referencedTable)
       .append(" (")
       .append(StringHelper.join(", ", primaryKey))
       .append(") ")
       .toString();
 }
Пример #9
0
 public static String createCollectionSubquery(
     JoinSequence joinSequence, Map enabledFilters, String[] columns) {
   try {
     JoinFragment join = joinSequence.toJoinFragment(enabledFilters, true);
     return new StringBuilder("select ")
         .append(StringHelper.join(", ", columns))
         .append(" from ")
         .append(join.toFromFragmentString().substring(2)) // remove initial ", "
         .append(" where ")
         .append(join.toWhereFragmentString().substring(5)) // remove initial " and "
         .toString();
   } catch (MappingException me) {
     throw new QueryException(me);
   }
 }
Пример #10
0
 @Override
 public String toString() {
   return '(' + StringHelper.join(' ' + nature.getOperator() + ' ', conditions.iterator()) + ')';
 }