Java 类org.hibernate.util.StringHelper 实例源码

项目:Equella    文件:LowercaseImprovedNamingScheme.java   
private String getColumnName(String columnName)
{
    if( columnName != null )
    {
        String col = columnOverrides.get(StringHelper.unqualify(columnName));
        if( col != null )
        {
            columnName = col;
        }
    }
    if( columnName != null && columnName.length() > 25 )
    {
        columnName = columnName.substring(0, 25);
    }
    return columnName;
}
项目:cacheonix-core    文件:FromElement.java   
public String getIdentityColumn() {
    checkInitialized();
    String table = getTableAlias();
    if ( table == null ) {
        throw new IllegalStateException( "No table alias for node " + this );
    }
    String[] cols;
    String propertyName;
    if ( getEntityPersister() != null && getEntityPersister().getEntityMetamodel() != null
            && getEntityPersister().getEntityMetamodel().hasNonIdentifierPropertyNamedId() ) {
        propertyName = getEntityPersister().getIdentifierPropertyName();
    }
    else {
        propertyName = EntityPersister.ENTITY_ID;
    }
    if ( getWalker().getStatementType() == HqlSqlWalker.SELECT ) {
        cols = getPropertyMapping( propertyName ).toColumns( table, propertyName );
    }
    else {
        cols = getPropertyMapping( propertyName ).toColumns( propertyName );
    }
    String result = StringHelper.join( ", ", cols );
    return  cols.length == 1 ? result : "(" + result + ")";
}
项目:cacheonix-core    文件:HbmBinder.java   
private static void parseFilter(Element filterElement, Filterable filterable, Mappings model) {
    final String name = filterElement.attributeValue( "name" );
    String condition = filterElement.getTextTrim();
    if ( StringHelper.isEmpty(condition) ) {
        condition = filterElement.attributeValue( "condition" );
    }
    //TODO: bad implementation, cos it depends upon ordering of mapping doc
    //      fixing this requires that Collection/PersistentClass gain access
    //      to the Mappings reference from Configuration (or the filterDefinitions
    //      map directly) sometime during Configuration.buildSessionFactory
    //      (after all the types/filter-defs are known and before building
    //      persisters).
    if ( StringHelper.isEmpty(condition) ) {
        condition = model.getFilterDefinition(name).getDefaultFilterCondition();
    }
    if ( condition==null) {
        throw new MappingException("no filter condition found for filter: " + name);
    }
    log.debug( "Applying filter [" + name + "] as [" + condition + "]" );
    filterable.addFilter( name, condition );
}
项目:cacheonix-core    文件:DefaultNamingStrategy.java   
/**
 * Returns either the table name if explicit or
 * if there is an associated table, the concatenation of owner entity table and associated table
 * otherwise the concatenation of owner entity table and the unqualified property name
 */
public String logicalCollectionTableName(String tableName,
                                         String ownerEntityTable, String associatedEntityTable, String propertyName
) {
    if ( tableName != null ) {
        return tableName;
    }
    else {
        //use of a stringbuffer to workaround a JDK bug
        return new StringBuffer(ownerEntityTable).append("_")
                .append(
                    associatedEntityTable != null ?
                    associatedEntityTable :
                    StringHelper.unqualify( propertyName )
                ).toString();
    }
}
项目:cacheonix-core    文件:LegacyTestCase.java   
public void configure(Configuration cfg) {
    super.configure( cfg );
    if ( !useAntlrParser ) {
        cfg.setProperty( Environment.QUERY_TRANSLATOR, ClassicQueryTranslatorFactory.class.getName() );
        try {
            String dialectTrueRepresentation = Dialect.getDialect().toBooleanValueString( true );
            // if this call succeeds, then the dialect is saying to represent true/false as int values...
            Integer.parseInt( dialectTrueRepresentation );
            String subs = cfg.getProperties().getProperty( Environment.QUERY_SUBSTITUTIONS );
            if ( subs == null ) {
                subs = "";
            }
            if ( StringHelper.isEmpty( subs ) ) {
                subs = "true=1, false=0";
            }
            else {
                subs += ", true=1, false=0";
            }
            cfg.getProperties().setProperty( Environment.QUERY_SUBSTITUTIONS, subs );
        }
        catch( NumberFormatException nfe ) {
            // the Integer#parseInt call failed...
        }
    }
}
项目:cacheonix-core    文件:PathHelper.java   
/**
 * Turns a path into an AST.
 *
 * @param path    The path.
 * @param factory The AST factory to use.
 * @return An HQL AST representing the path.
 */
public static AST parsePath(String path, ASTFactory factory) {
    String[] identifiers = StringHelper.split( ".", path );
    AST lhs = null;
    for ( int i = 0; i < identifiers.length; i++ ) {
        String identifier = identifiers[i];
        AST child = ASTUtil.create( factory, HqlSqlTokenTypes.IDENT, identifier );
        if ( i == 0 ) {
            lhs = child;
        }
        else {
            lhs = ASTUtil.createBinarySubtree( factory, HqlSqlTokenTypes.DOT, ".", lhs, child );
        }
    }
    if ( log.isDebugEnabled() ) {
        log.debug( "parsePath() : " + path + " -> " + ASTUtil.getDebugString( lhs ) );
    }
    return lhs;
}
项目:cacheonix-core    文件:SAPDBDialect.java   
public String getAddForeignKeyConstraintString(
        String constraintName, 
        String[] foreignKey, 
        String referencedTable, 
        String[] primaryKey, boolean referencesPrimaryKey
) {
    StringBuffer res = new StringBuffer(30)
        .append(" foreign key ")
        .append(constraintName)
        .append(" (")
        .append( StringHelper.join(", ", foreignKey) )
        .append(") references ")
        .append(referencedTable);

    if(!referencesPrimaryKey) {
        res.append(" (")
           .append( StringHelper.join(", ", primaryKey) )
           .append(')');
    }

    return res.toString();
}
项目:cacheonix-core    文件:PropertyAccessorFactory.java   
/**
 * Retreives a PropertyAccessor specific for a PojoRepresentation with the given access strategy.
 *
 * @param pojoAccessorStrategy The access strategy.
 * @return An appropriate accessor.
 */
private static PropertyAccessor getPojoPropertyAccessor(String pojoAccessorStrategy) {
    if ( StringHelper.isEmpty( pojoAccessorStrategy ) || "property".equals( pojoAccessorStrategy ) ) {
        return BASIC_PROPERTY_ACCESSOR;
    }
    else if ( "field".equals( pojoAccessorStrategy ) ) {
        return DIRECT_PROPERTY_ACCESSOR;
    }
    else if ( "embedded".equals( pojoAccessorStrategy ) ) {
        return EMBEDDED_PROPERTY_ACCESSOR;
    }
    else if ( "noop".equals(pojoAccessorStrategy) ) {
        return NOOP_ACCESSOR;
    }
    else {
        return resolveCustomAccessor( pojoAccessorStrategy );
    }
}
项目:cacheonix-core    文件:OSCacheProvider.java   
/**
 * Builds a new {@link Cache} instance, and gets it's properties from the OSCache {@link Config}
 * which reads the properties file (<code>oscache.properties</code>) from the classpath.
 * If the file cannot be found or loaded, an the defaults are used.
 *
 * @param region
 * @param properties
 * @return
 * @throws CacheException
 */
public Cache buildCache(String region, Properties properties) throws CacheException {

    int refreshPeriod = PropertiesHelper.getInt(
        StringHelper.qualify(region, OSCACHE_REFRESH_PERIOD),
        OSCACHE_PROPERTIES,
        CacheEntry.INDEFINITE_EXPIRY
    );
    String cron = OSCACHE_PROPERTIES.getProperty( StringHelper.qualify(region, OSCACHE_CRON) );

    // construct the cache
    final OSCache cache = new OSCache(refreshPeriod, cron, region);

    Integer capacity = PropertiesHelper.getInteger( StringHelper.qualify(region, OSCACHE_CAPACITY), OSCACHE_PROPERTIES );
    if ( capacity!=null ) cache.setCacheCapacity( capacity.intValue() );

    return cache;
}
项目:cacheonix-core    文件:Dialect.java   
/**
 * The syntax used to add a foreign key constraint to a table.
 *
 * @param constraintName The FK constraint name.
 * @param foreignKey The names of the columns comprising the FK
 * @param referencedTable The table referenced by the FK
 * @param primaryKey The explicit columns in the referencedTable referenced
 * by this FK.
 * @param referencesPrimaryKey if false, constraint should be
 * explicit about which column names the constraint refers to
 *
 * @return the "add FK" fragment
 */
public String getAddForeignKeyConstraintString(
        String constraintName,
        String[] foreignKey,
        String referencedTable,
        String[] primaryKey,
        boolean referencesPrimaryKey) {
    StringBuffer res = new StringBuffer( 30 );

    res.append( " add constraint " )
            .append( constraintName )
            .append( " foreign key (" )
            .append( StringHelper.join( ", ", foreignKey ) )
            .append( ") references " )
            .append( referencedTable );

    if ( !referencesPrimaryKey ) {
        res.append( " (" )
                .append( StringHelper.join( ", ", primaryKey ) )
                .append( ')' );
    }

    return res.toString();
}
项目:cacheonix-core    文件:CollectionJoinWalker.java   
protected StringBuffer whereString(String alias, String[] columnNames, String subselect, int batchSize) {
    if (subselect==null) {
        return super.whereString(alias, columnNames, batchSize);
    }
    else {
        StringBuffer buf = new StringBuffer();
        if (columnNames.length>1) buf.append('(');
        buf.append( StringHelper.join(", ", StringHelper.qualify(alias, columnNames) ) );
        if (columnNames.length>1) buf.append(')');
        buf.append(" in ")
            .append('(')
            .append(subselect) 
            .append(')');
        return buf;
    }
}
项目:cacheonix-core    文件:WhereParser.java   
private void preprocess(String token, QueryTranslatorImpl q) throws QueryException {
    // ugly hack for cases like "elements(foo.bar.collection)"
    // (multi-part path expression ending in elements or indices)
    String[] tokens = StringHelper.split( ".", token, true );
    if (
            tokens.length > 5 &&
            ( CollectionPropertyNames.COLLECTION_ELEMENTS.equals( tokens[tokens.length - 1] )
            || CollectionPropertyNames.COLLECTION_INDICES.equals( tokens[tokens.length - 1] ) )
    ) {
        pathExpressionParser.start( q );
        for ( int i = 0; i < tokens.length - 3; i++ ) {
            pathExpressionParser.token( tokens[i], q );
        }
        pathExpressionParser.token( null, q );
        pathExpressionParser.end( q );
        addJoin( pathExpressionParser.getWhereJoin(), q );
        pathExpressionParser.ignoreInitialJoin();
    }
}
项目:cacheonix-core    文件:AbstractPropertyMapping.java   
public String[] toColumns(String alias, String propertyName) throws QueryException {
    //TODO: *two* hashmap lookups here is one too many...
    String[] columns = (String[]) columnsByPropertyPath.get(propertyName);
    if ( columns == null ) {
        throw propertyException( propertyName );
    }
    String[] templates = (String[]) formulaTemplatesByPropertyPath.get(propertyName);
    String[] result = new String[columns.length];
    for ( int i=0; i<columns.length; i++ ) {
        if ( columns[i]==null ) {
            result[i] = StringHelper.replace( templates[i], Template.TEMPLATE, alias );
        }
        else {
            result[i] = StringHelper.qualify( alias, columns[i] );
        }
    }
    return result;
}
项目:cacheonix-core    文件:DatabaseMetadata.java   
public boolean isTable(Object key) throws HibernateException {
    if(key instanceof String) {
    Table tbl = new Table((String)key);
    if ( getTableMetadata( tbl.getName(), tbl.getSchema(), tbl.getCatalog(), tbl.isQuoted() ) != null ) {
            return true;
        } else {
            String[] strings = StringHelper.split(".", (String) key);
            if(strings.length==3) {
            tbl = new Table(strings[2]);
            tbl.setCatalog(strings[0]);
            tbl.setSchema(strings[1]);
            return getTableMetadata( tbl.getName(), tbl.getSchema(), tbl.getCatalog(), tbl.isQuoted() ) != null;
            } else if (strings.length==2) {
            tbl = new Table(strings[1]);
            tbl.setSchema(strings[0]);
            return getTableMetadata( tbl.getName(), tbl.getSchema(), tbl.getCatalog(), tbl.isQuoted() ) != null;
            }
        }
    }
    return false;
}
项目:cacheonix-core    文件:JoinHelper.java   
/**
 * Get the aliased columns of the owning entity which are to 
 * be used in the join
 */
public static String[] getAliasedLHSColumnNames(
        AssociationType type, 
        String alias, 
        int property, 
        int begin, 
        OuterJoinLoadable lhsPersister,
        Mapping mapping
) {
    if ( type.useLHSPrimaryKey() ) {
        return StringHelper.qualify( alias, lhsPersister.getIdentifierColumnNames() );
    }
    else {
        String propertyName = type.getLHSPropertyName();
        if (propertyName==null) {
            return ArrayHelper.slice( 
                    lhsPersister.toColumns(alias, property), 
                    begin, 
                    type.getColumnSpan(mapping) 
                );
        }
        else {
            return ( (PropertyMapping) lhsPersister ).toColumns(alias, propertyName); //bad cast
        }
    }
}
项目:cacheonix-core    文件:SessionImpl.java   
public int delete(String query, Object[] values, Type[] types) throws HibernateException {
    errorIfClosed();
    checkTransactionSynchStatus();
    if ( query == null ) {
        throw new IllegalArgumentException("attempt to perform delete-by-query with null query");
    }

    if ( log.isTraceEnabled() ) {
        log.trace( "delete: " + query );
        if ( values.length != 0 ) {
            log.trace( "parameters: " + StringHelper.toString( values ) );
        }
    }

    List list = find( query, values, types );
    int deletionCount = list.size();
    for ( int i = 0; i < deletionCount; i++ ) {
        delete( list.get( i ) );
    }

    return deletionCount;
}
项目:Equella    文件:LowercaseImprovedNamingScheme.java   
@Override
/**
 * Copied from EJB3NamingStrategy
 */
public String foreignKeyColumnName(String propertyName, String propertyEntityName, String propertyTableName,
    String referencedColumnName)
{
    String header = propertyName != null ? StringHelper.unqualify(propertyName) : propertyTableName;
    if( header == null )
    {
        throw new AssertionFailure("NammingStrategy not properly filled");
    }
    return columnName(header + "_" + referencedColumnName);
}
项目:hazelcast-hibernate    文件:CacheEnvironment.java   
public static String getConfigFilePath(Properties props) {
    String configResourcePath = PropertiesHelper.getString(CacheEnvironment.CONFIG_FILE_PATH_LEGACY, props, null);
    if (StringHelper.isEmpty(configResourcePath)) {
        configResourcePath = PropertiesHelper.getString(CacheEnvironment.CONFIG_FILE_PATH, props, null);
    }
    return configResourcePath;
}
项目:cacheonix-core    文件:HbmBinder.java   
private static void bindImport(Element importNode, Mappings mappings) {
    String className = getClassName( importNode.attribute( "class" ), mappings );
    Attribute renameNode = importNode.attribute( "rename" );
    String rename = ( renameNode == null ) ?
                    StringHelper.unqualify( className ) :
                    renameNode.getValue();
    log.debug( "Import: " + rename + " -> " + className );
    mappings.addImport( className, rename );
}
项目:cacheonix-core    文件:HbmBinder.java   
private static void bindDom4jRepresentation(Element node, PersistentClass entity,
        Mappings mappings, java.util.Map inheritedMetas) {
    String nodeName = node.attributeValue( "node" );
    if (nodeName==null) nodeName = StringHelper.unqualify( entity.getEntityName() );
    entity.setNodeName(nodeName);

    Element tuplizer = locateTuplizerDefinition( node, EntityMode.DOM4J );
    if ( tuplizer != null ) {
        entity.addTuplizer( EntityMode.DOM4J, tuplizer.attributeValue( "class" ) );
    }
}
项目:cacheonix-core    文件:Delete.java   
public String toStatementString() {
    StringBuffer buf = new StringBuffer( tableName.length() + 10 );
    if ( comment!=null ) {
        buf.append( "/* " ).append(comment).append( " */ " );
    }
    buf.append( "delete from " ).append(tableName);
    if ( where != null || primaryKeyColumnNames != null || versionColumnName != null ) {
        buf.append( " where " );
    }
    boolean conditionsAppended = false;
    if ( primaryKeyColumnNames != null ) {
        buf.append( StringHelper.join( "=? and ", primaryKeyColumnNames ) ).append( "=?" );
        conditionsAppended = true;
    }
    if ( where!=null ) {
        if ( conditionsAppended ) {
            buf.append( " and " );
        }
        buf.append( where );
        conditionsAppended = true;
    }
    if ( versionColumnName!=null ) {
        if ( conditionsAppended ) {
            buf.append( " and " );
        }
        buf.append( versionColumnName ).append( "=?" );
    }
    return buf.toString();
}
项目:cacheonix-core    文件:ForUpdateFragment.java   
public ForUpdateFragment(Dialect dialect, Map lockModes, Map keyColumnNames) throws QueryException {
    this( dialect );
    LockMode upgradeType = null;
    Iterator iter = lockModes.entrySet().iterator();
    while ( iter.hasNext() ) {
        final Map.Entry me = ( Map.Entry ) iter.next();
        final LockMode lockMode = ( LockMode ) me.getValue();
        if ( LockMode.READ.lessThan( lockMode ) ) {
            final String tableAlias = ( String ) me.getKey();
            if ( dialect.forUpdateOfColumns() ) {
                String[] keyColumns = ( String[] ) keyColumnNames.get( tableAlias ); //use the id column alias
                if ( keyColumns == null ) {
                    throw new IllegalArgumentException( "alias not found: " + tableAlias );
                }
                keyColumns = StringHelper.qualify( tableAlias, keyColumns );
                for ( int i = 0; i < keyColumns.length; i++ ) {
                    addTableAlias( keyColumns[i] );
                }
            }
            else {
                addTableAlias( tableAlias );
            }
            if ( upgradeType != null && lockMode != upgradeType ) {
                throw new QueryException( "mixed LockModes" );
            }
            upgradeType = lockMode;
        }
    }

    if ( upgradeType == LockMode.UPGRADE_NOWAIT ) {
        setNowaitEnabled( true );
    }
}
项目:cacheonix-core    文件:Mappings.java   
public PersistentClass locatePersistentClassByEntityName(String entityName) {
    PersistentClass persistentClass = ( PersistentClass ) classes.get( entityName );
    if ( persistentClass == null ) {
        String actualEntityName = ( String ) imports.get( entityName );
        if ( StringHelper.isNotEmpty( actualEntityName ) ) {
            persistentClass = ( PersistentClass ) classes.get( actualEntityName );
        }
    }
    return persistentClass;
}
项目:cacheonix-core    文件:DefaultNamingStrategy.java   
/**
 * Return the unqualified property name, not the best strategy but a backward compatible one
 */
public String collectionTableName(
        String ownerEntity, String ownerEntityTable, String associatedEntity, String associatedEntityTable,
        String propertyName
) {
    //use a degenerated strategy for backward compatibility
    return StringHelper.unqualify(propertyName);
}
项目:cacheonix-core    文件:DefaultNamingStrategy.java   
/**
 * Return the property name or propertyTableName
 */
public String foreignKeyColumnName(
        String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName
) {
    String header = propertyName != null ? StringHelper.unqualify( propertyName ) : propertyTableName;
    if (header == null) throw new AssertionFailure("NammingStrategy not properly filled");
    return columnName( header ); //+ "_" + referencedColumnName not used for backward compatibility
}
项目:cacheonix-core    文件:ImprovedNamingStrategy.java   
/**
 * Return the property name or propertyTableName
 */
public String foreignKeyColumnName(
        String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName
) {
    String header = propertyName != null ? StringHelper.unqualify( propertyName ) : propertyTableName;
    if (header == null) throw new AssertionFailure("NamingStrategy not properly filled");
    return columnName( header ); //+ "_" + referencedColumnName not used for backward compatibility
}
项目:cacheonix-core    文件:Index.java   
public static String buildSqlDropIndexString(
        Dialect dialect,
        Table table,
        String name,
        String defaultCatalog,
        String defaultSchema
) {
    return "drop index " +
            StringHelper.qualify(
                    table.getQualifiedName( dialect, defaultCatalog, defaultSchema ),
                    name
            );
}
项目:cacheonix-core    文件:Index.java   
public static String buildSqlCreateIndexString(
        Dialect dialect,
        String name,
        Table table,
        Iterator columns,
        boolean unique,
        String defaultCatalog,
        String defaultSchema
) {
    //TODO handle supportsNotNullUnique=false, but such a case does not exist in the wild so far
    StringBuffer buf = new StringBuffer( "create" )
            .append( unique ?
                    " unique" :
                    "" )
            .append( " index " )
            .append( dialect.qualifyIndexName() ?
                    name :
                    StringHelper.unqualify( name ) )
            .append( " on " )
            .append( table.getQualifiedName( dialect, defaultCatalog, defaultSchema ) )
            .append( " (" );
    Iterator iter = columns;
    while ( iter.hasNext() ) {
        buf.append( ( (Column) iter.next() ).getQuotedName( dialect ) );
        if ( iter.hasNext() ) buf.append( ", " );
    }
    buf.append( ")" );
    return buf.toString();
}
项目:cacheonix-core    文件:Node.java   
public void initialize(Token tok) {
    super.initialize(tok);
    filename = tok.getFilename();
    line = tok.getLine();
    column = tok.getColumn();
    String text = tok.getText();
    textLength = StringHelper.isEmpty(text) ? 0 : text.length();
}
项目:cacheonix-core    文件:PersistentClass.java   
public Property getProperty(String propertyName) throws MappingException {
    Iterator iter = getPropertyClosureIterator();
    Property identifierProperty = getIdentifierProperty();
    if ( identifierProperty != null
            && identifierProperty.getName().equals( StringHelper.root(propertyName) )
            ) {
        return identifierProperty;
    }
    else {
        return getProperty( propertyName, iter );
    }
}
项目:cacheonix-core    文件:Formatter.java   
public Formatter(String sql) {
    tokens = new StringTokenizer(
            sql, 
            "()+*/-=<>'`\"[]," + StringHelper.WHITESPACE, 
            true
        );
}
项目:cacheonix-core    文件:Example.java   
protected void addComponentTypedValues(
        String path, 
        Object component, 
        AbstractComponentType type, 
        List list, 
        Criteria criteria, 
        CriteriaQuery criteriaQuery)
throws HibernateException {

    if (component!=null) {
        String[] propertyNames = type.getPropertyNames();
        Type[] subtypes = type.getSubtypes();
        Object[] values = type.getPropertyValues( component, getEntityMode(criteria, criteriaQuery) );
        for (int i=0; i<propertyNames.length; i++) {
            Object value = values[i];
            Type subtype = subtypes[i];
            String subpath = StringHelper.qualify( path, propertyNames[i] );
            if ( isPropertyIncluded(value, subpath, subtype) ) {
                if ( subtype.isComponentType() ) {
                    addComponentTypedValues(subpath, value, (AbstractComponentType) subtype, list, criteria, criteriaQuery);
                }
                else {
                    addPropertyTypedValue(value, subtype, list);
                }
            }
        }
    }
}
项目:cacheonix-core    文件:BetweenExpression.java   
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
throws HibernateException {
    return StringHelper.join(
        " and ",
        StringHelper.suffix( criteriaQuery.getColumnsUsingProjection(criteria, propertyName), " between ? and ?" )
    );

    //TODO: get SQL rendering out of this package!
}
项目:cacheonix-core    文件:NotNullExpression.java   
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
throws HibernateException {
    String[] columns = criteriaQuery.getColumnsUsingProjection(criteria, propertyName);
    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!
}
项目:cacheonix-core    文件:IdentifierEqExpression.java   
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
throws HibernateException {

    String[] columns = criteriaQuery.getIdentifierColumns(criteria);

    String result = StringHelper.join(
        " and ",
        StringHelper.suffix( columns, " = ?" )
    );
    if (columns.length>1) result = '(' + result + ')';
    return result;

    //TODO: get SQL rendering out of this package!
}
项目:cacheonix-core    文件:SQLProjection.java   
public String toSqlString(
        Criteria criteria, 
        int loc, 
        CriteriaQuery criteriaQuery)
throws HibernateException {
    return StringHelper.replace( sql, "{alias}", criteriaQuery.getSQLAlias(criteria) );
}
项目:cacheonix-core    文件:InExpression.java   
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
throws HibernateException {
    String[] columns = criteriaQuery.getColumnsUsingProjection(criteria, propertyName);
    String singleValueParam = StringHelper.repeat( "?, ", columns.length-1 )  + "?";
    if ( columns.length>1 ) singleValueParam = '(' + singleValueParam + ')';
    String params = values.length>0 ?
        StringHelper.repeat( singleValueParam + ", ", values.length-1 ) + singleValueParam :
        "";
    String cols = StringHelper.join(", ", columns);
    if ( columns.length>1 ) cols = '(' + cols + ')';
    return cols + " in (" + params + ')';
}
项目:cacheonix-core    文件:JoinFragment.java   
/**
 * Appends the 'on' condition to the buffer, returning true if the condition was added.
 * Returns false if the 'on' condition was empty.
 *
 * @param buffer The buffer to append the 'on' condition to.
 * @param on     The 'on' condition.
 * @return Returns true if the condition was added, false if the condition was already in 'on' string.
 */
protected boolean addCondition(StringBuffer buffer, String on) {
    if ( StringHelper.isNotEmpty( on ) ) {
        if ( !on.startsWith( " and" ) ) buffer.append( " and " );
        buffer.append( on );
        return true;
    }
    else {
        return false;
    }
}
项目:cacheonix-core    文件:NullExpression.java   
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) 
throws HibernateException {
    String[] columns = criteriaQuery.getColumnsUsingProjection(criteria, propertyName);
    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!
}
项目:cacheonix-core    文件:IdentifierProjection.java   
public String toGroupSqlString(Criteria criteria, CriteriaQuery criteriaQuery) 
throws HibernateException {
    if (!grouped) {
        return super.toGroupSqlString(criteria, criteriaQuery);
    }
    else {
        return StringHelper.join( ", ", criteriaQuery.getIdentifierColumns(criteria) );
    }
}