@Override public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException { final String[] columns = criteriaQuery.findColumns( propertyName, criteria ); String result = String.join( " or ", StringHelper.suffix( columns, " is not null" ) ); if ( columns.length > 1 ) { result = '(' + result + ')'; } return result; }
@Override public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException { final String[] columns = criteriaQuery.findColumns( propertyName, criteria ); final String[] expressions = StringHelper.suffix( columns, " between ? and ?" ); return String.join( " and ", expressions ); }
@Override public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException { final String[] columns = criteriaQuery.findColumns( propertyName, criteria ); String result = String.join( " and ", StringHelper.suffix( columns, " is null" ) ); if ( columns.length > 1 ) { result = '(' + result + ')'; } return result; }
@Override public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException { final String[] lhsColumns = criteriaQuery.findColumns( propertyName, criteria ); final String[] rhsColumns = criteriaQuery.findColumns( otherPropertyName, criteria ); final String[] comparisons = StringHelper.add( lhsColumns, getOp(), rhsColumns ); if ( comparisons.length > 1 ) { return '(' + String.join( " and ", comparisons ) + ')'; } else { return comparisons[0]; } }
/** * Determines the column name corresponding to the specified property path. * * @param propertyName The property path * @param criteria The criteria * @param criteriaQuery The criteria query * * @return The column name * * @throws HibernateException If the property could not be resolved, or more than one column is mapped by the property path. */ public static String findColumn(String propertyName, Criteria criteria, CriteriaQuery criteriaQuery) { final String[] columns = criteriaQuery.findColumns( propertyName, criteria ); if ( columns.length != 1 ) { throw new HibernateException( "Spatial Expression may only be used with single-column properties" ); } return columns[0]; } }
/** * Get the names of the columns mapped by a property path; if the * property path is not found in subcriteria, try the "outer" query. * Projection aliases are ignored. */ @Override public String[] findColumns(String propertyName, Criteria subcriteria ) throws HibernateException { try { return getColumns( propertyName, subcriteria ); } catch ( HibernateException he ) { //not found in inner query, try the outer query if ( outerQueryTranslator != null ) { return outerQueryTranslator.findColumns( propertyName, subcriteria ); } else { throw he; } } }
@Override public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException { final String[] columns = criteriaQuery.findColumns( propertyName, criteria ); final Type type = criteriaQuery.getTypeUsingProjection( criteria, propertyName ); final StringBuilder fragment = new StringBuilder(); if ( columns.length > 1 ) { fragment.append( '(' ); } final SessionFactoryImplementor factory = criteriaQuery.getFactory(); final int[] sqlTypes = type.sqlTypes( factory ); for ( int i = 0; i < columns.length; i++ ) { final boolean lower = ignoreCase && (sqlTypes[i] == Types.VARCHAR || sqlTypes[i] == Types.CHAR || sqlTypes[i] == Types.NVARCHAR || sqlTypes[i] == Types.NCHAR); if ( lower ) { fragment.append( factory.getDialect().getLowercaseFunction() ).append( '(' ); } fragment.append( columns[i] ); if ( lower ) { fragment.append( ')' ); } fragment.append( getOp() ).append( "?" ); if ( i < columns.length - 1 ) { fragment.append( " and " ); } } if ( columns.length > 1 ) { fragment.append( ')' ); } return fragment.toString(); }
@Override public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) { final Dialect dialect = criteriaQuery.getFactory().getDialect(); final String[] columns = criteriaQuery.findColumns( propertyName, criteria ); if ( columns.length != 1 ) { throw new HibernateException( "ilike may only be used with single-column properties" ); } if ( dialect instanceof PostgreSQLDialect || dialect instanceof PostgreSQL81Dialect) { return columns[0] + " ilike ?"; } else { return dialect.getLowercaseFunction() + '(' + columns[0] + ") like ?"; } }
@Override public String toSqlString( Criteria criteria, CriteriaQuery criteriaQuery ) { final String[] columns = criteriaQuery.findColumns( propertyName, criteria ); if ( criteriaQuery.getFactory().getDialect().supportsRowValueConstructorSyntaxInInList() || columns.length <= 1 ) { String singleValueParam = StringHelper.repeat( "?, ", columns.length - 1 ) + "?"; if ( columns.length > 1 ) { singleValueParam = '(' + singleValueParam + ')'; } final String params = values.length > 0 ? StringHelper.repeat( singleValueParam + ", ", values.length - 1 ) + singleValueParam : ""; String cols = String.join( ", ", columns ); if ( columns.length > 1 ) { cols = '(' + cols + ')'; } return cols + " in (" + params + ')'; } else { String cols = " ( " + String.join( " = ? and ", columns ) + "= ? ) "; cols = values.length > 0 ? StringHelper.repeat( cols + "or ", values.length - 1 ) + cols : ""; cols = " ( " + cols + " ) "; return cols; } }
@Override public String toSqlString(Criteria criteria,CriteriaQuery criteriaQuery) { final Dialect dialect = criteriaQuery.getFactory().getDialect(); final String[] columns = criteriaQuery.findColumns( propertyName, criteria ); if ( columns.length != 1 ) { throw new HibernateException( "Like may only be used with single-column properties" ); } final String escape = escapeChar == null ? "" : " escape \'" + escapeChar + "\'"; final String column = columns[0]; if ( ignoreCase ) { if ( dialect.supportsCaseInsensitiveLike() ) { return column +" " + dialect.getCaseInsensitiveLike() + " ?" + escape; } else { return dialect.getLowercaseFunction() + '(' + column + ')' + " like ?" + escape; } } else { return column + " like ?" + escape; } }
public static String findColumn(String propertyName, Criteria criteria, CriteriaQuery criteriaQuery) { String[] columns = criteriaQuery.findColumns(propertyName, criteria); if (columns.length != 1) throw new HibernateException("Spatial Expression may only be used with single-column properties"); return columns[0]; } }
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException { String[] xcols = criteriaQuery.findColumns(propertyName, criteria); String[] ycols = criteriaQuery.findColumns(otherPropertyName, criteria); String result = StringHelper.join( " and ", StringHelper.add( xcols, getOp(), ycols ) ); if (xcols.length>1) result = '(' + result + ')'; return result; //TODO: get SQL rendering out of this package! }
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException { String[] xcols = criteriaQuery.findColumns(propertyName, criteria); String[] ycols = criteriaQuery.findColumns(otherPropertyName, criteria); String result = StringHelper.join( " and ", StringHelper.add( xcols, getOp(), ycols ) ); if (xcols.length>1) result = '(' + result + ')'; return result; //TODO: get SQL rendering out of this package! }
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! }
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! }
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException { return StringHelper.join( " and ", StringHelper.suffix( criteriaQuery.findColumns(propertyName, criteria), " between ? and ?" ) ); //TODO: get SQL rendering out of this package! }
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException { String[] columns = criteriaQuery.findColumns(propertyName, criteria); String result = StringHelper.join( " or ", StringHelper.suffix( columns, " is not null" ) ); if (columns.length>1) result = '(' + result + ')'; return result; //TODO: get SQL rendering out of this package! }
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException { String[] columns = criteriaQuery.findColumns(propertyName, criteria); String result = StringHelper.join( " or ", StringHelper.suffix( columns, " is not null" ) ); if (columns.length>1) result = '(' + result + ')'; return result; //TODO: get SQL rendering out of this package! }
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException { return StringHelper.join( " and ", StringHelper.suffix( criteriaQuery.findColumns(propertyName, criteria), " between ? and ?" ) ); //TODO: get SQL rendering out of this package! }
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException { Dialect dialect = criteriaQuery.getFactory().getDialect(); String[] columns = criteriaQuery.findColumns( propertyName, criteria ); if ( columns.length != 1 ) { throw new HibernateException( "ilike may only be used with single-column properties" ); } if ( dialect instanceof PostgreSQLDialect ) { return columns[0] + " ilike ?"; } else { return dialect.getLowercaseFunction() + '(' + columns[0] + ") like ?"; } //TODO: get SQL rendering out of this package! }