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

项目:lams    文件:DDLFormatterImpl.java   
@Override
public String format(String sql) {
    if ( StringHelper.isEmpty( sql ) ) {
        return sql;
    }
    if ( sql.toLowerCase().startsWith( "create table" ) ) {
        return formatCreateTable( sql );
    }
    else if ( sql.toLowerCase().startsWith( "alter table" ) ) {
        return formatAlterTable( sql );
    }
    else if ( sql.toLowerCase().startsWith( "comment on" ) ) {
        return formatCommentOn( sql );
    }
    else {
        return "\n    " + sql;
    }
}
项目:lams    文件:HbmBinder.java   
private static String getClassTableName(
        PersistentClass model,
        Element node,
        String schema,
        String catalog,
        Table denormalizedSuperTable,
        Mappings mappings) {
    Attribute tableNameNode = node.attribute( "table" );
    String logicalTableName;
    String physicalTableName;
    if ( tableNameNode == null ) {
        logicalTableName = StringHelper.unqualify( model.getEntityName() );
        physicalTableName = getNamingStrategyDelegate( mappings ).determineImplicitPrimaryTableName(
                model.getEntityName(),
                model.getJpaEntityName()
        );
    }
    else {
        logicalTableName = tableNameNode.getValue();
        physicalTableName = getNamingStrategyDelegate( mappings ).toPhysicalTableName( logicalTableName );
    }
    mappings.addTableBinding( schema, catalog, logicalTableName, physicalTableName, denormalizedSuperTable );
    return physicalTableName;
}
项目:lams    文件:HbmBinder.java   
private static void parseFilterDef(Element element, Mappings mappings) {
    String name = element.attributeValue( "name" );
    LOG.debugf( "Parsing filter-def [%s]", name );
    String defaultCondition = element.getTextTrim();
    if ( StringHelper.isEmpty( defaultCondition ) ) {
        defaultCondition = element.attributeValue( "condition" );
    }
    HashMap paramMappings = new HashMap();
    Iterator params = element.elementIterator( "filter-param" );
    while ( params.hasNext() ) {
        final Element param = (Element) params.next();
        final String paramName = param.attributeValue( "name" );
        final String paramType = param.attributeValue( "type" );
        LOG.debugf( "Adding filter parameter : %s -> %s", paramName, paramType );
        final Type heuristicType = mappings.getTypeResolver().heuristicType( paramType );
        LOG.debugf( "Parameter heuristic type : %s", heuristicType );
        paramMappings.put( paramName, heuristicType );
    }
    LOG.debugf( "Parsed filter-def [%s]", name );
    FilterDefinition def = new FilterDefinition( name, defaultCondition, paramMappings );
    mappings.addFilterDefinition( def );
}
项目:lams    文件:ToOneFkSecondPass.java   
public void doSecondPass(java.util.Map persistentClasses) throws MappingException {
    if ( value instanceof ManyToOne ) {
        ManyToOne manyToOne = (ManyToOne) value;
        PersistentClass ref = (PersistentClass) persistentClasses.get( manyToOne.getReferencedEntityName() );
        if ( ref == null ) {
            throw new AnnotationException(
                    "@OneToOne or @ManyToOne on "
                            + StringHelper.qualify( entityClassName, path )
                            + " references an unknown entity: "
                            + manyToOne.getReferencedEntityName()
            );
        }
        BinderHelper.createSyntheticPropertyReference( columns, ref, null, manyToOne, false, mappings );
        TableBinder.bindFk( ref, null, columns, manyToOne, unique, mappings );
        /*
         * HbmMetadataSourceProcessorImpl does this only when property-ref != null, but IMO, it makes sense event if it is null
         */
        if ( !manyToOne.isIgnoreNotFound() ) manyToOne.createPropertyRefConstraints( persistentClasses );
    }
    else if ( value instanceof OneToOne ) {
        value.createForeignKey();
    }
    else {
        throw new AssertionFailure( "FkSecondPass for a wrong value type: " + value.getClass().getName() );
    }
}
项目:lams    文件:SQLExceptionConverterFactory.java   
/**
 * Build a SQLExceptionConverter instance.
 * <p/>
 * First, looks for a {@link Environment#SQL_EXCEPTION_CONVERTER} property to see
 * if the configuration specified the class of a specific converter to use.  If this
 * property is set, attempt to construct an instance of that class.  If not set, or
 * if construction fails, the converter specific to the dialect will be used.
 *
 * @param dialect    The defined dialect.
 * @param properties The configuration properties.
 * @return An appropriate SQLExceptionConverter instance.
 * @throws HibernateException There was an error building the SQLExceptionConverter.
 */
public static SQLExceptionConverter buildSQLExceptionConverter(Dialect dialect, Properties properties) throws HibernateException {
    SQLExceptionConverter converter = null;

    String converterClassName = (String) properties.get( Environment.SQL_EXCEPTION_CONVERTER );
    if ( StringHelper.isNotEmpty( converterClassName ) ) {
        converter = constructConverter( converterClassName, dialect.getViolatedConstraintNameExtracter() );
    }

    if ( converter == null ) {
        LOG.trace( "Using dialect defined converter" );
        converter = dialect.buildSQLExceptionConverter();
    }

    if ( converter instanceof Configurable ) {
        try {
            ( (Configurable) converter ).configure( properties );
        }
        catch (HibernateException e) {
            LOG.unableToConfigureSqlExceptionConverter( e );
            throw e;
        }
    }

    return converter;
}
项目:lams    文件: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();
    }
}
项目:lams    文件: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();
    }
}
项目:lams    文件:AbstractLoadPlanBuildingAssociationVisitationStrategy.java   
@Override
public boolean startingAttribute(AttributeDefinition attributeDefinition) {
    log.tracef(
            "%s Starting attribute %s",
            StringHelper.repeat( ">>", fetchSourceStack.size() ),
            attributeDefinition
    );

    final Type attributeType = attributeDefinition.getType();

    final boolean isComponentType = attributeType.isComponentType();
    final boolean isAssociationType = attributeType.isAssociationType();
    final boolean isBasicType = ! ( isComponentType || isAssociationType );
    currentPropertyPath = currentPropertyPath.append( attributeDefinition.getName() );
    if ( isBasicType ) {
        return true;
    }
    else if ( isAssociationType ) {
        // also handles any type attributes...
        return handleAssociationAttribute( (AssociationAttributeDefinition) attributeDefinition );
    }
    else {
        return handleCompositeAttribute( attributeDefinition );
    }
}
项目:lams    文件:JPAOverriddenAnnotationReader.java   
private JoinTable buildJoinTable(Element tree, XMLContext.Default defaults) {
    Element subelement = tree == null ? null : tree.element( "join-table" );
    final Class<JoinTable> annotationType = JoinTable.class;
    if ( subelement == null ) {
        return null;
    }
    //ignore java annotation, an element is defined
    AnnotationDescriptor annotation = new AnnotationDescriptor( annotationType );
    copyStringAttribute( annotation, subelement, "name", false );
    copyStringAttribute( annotation, subelement, "catalog", false );
    if ( StringHelper.isNotEmpty( defaults.getCatalog() )
            && StringHelper.isEmpty( (String) annotation.valueOf( "catalog" ) ) ) {
        annotation.setValue( "catalog", defaults.getCatalog() );
    }
    copyStringAttribute( annotation, subelement, "schema", false );
    if ( StringHelper.isNotEmpty( defaults.getSchema() )
            && StringHelper.isEmpty( (String) annotation.valueOf( "schema" ) ) ) {
        annotation.setValue( "schema", defaults.getSchema() );
    }
    buildUniqueConstraints( annotation, subelement );
    buildIndex( annotation, subelement );
    annotation.setValue( "joinColumns", getJoinColumns( subelement, false ) );
    annotation.setValue( "inverseJoinColumns", getJoinColumns( subelement, true ) );
    return AnnotationFactory.create( annotation );
}
项目:lams    文件:PersistentClass.java   
public void validate(Mapping mapping) throws MappingException {
    Iterator iter = getPropertyIterator();
    while ( iter.hasNext() ) {
        Property prop = (Property) iter.next();
        if ( !prop.isValid(mapping) ) {
            throw new MappingException(
                    "property mapping has wrong number of columns: " +
                    StringHelper.qualify( getEntityName(), prop.getName() ) +
                    " type: " +
                    prop.getType().getName()
                );
        }
    }
    checkPropertyDuplication();
    checkColumnDuplication();
}
项目:lams    文件:JoinImpl.java   
public JoinImpl(
        QuerySpace leftHandSide,
        String lhsPropertyName,
        QuerySpace rightHandSide,
        String[] rhsColumnNames,
        Type joinedPropertyType,
        boolean rightHandSideRequired) {
    this.leftHandSide = leftHandSide;
    this.lhsPropertyName = lhsPropertyName;
    this.rightHandSide = rightHandSide;
    this.rhsColumnNames = rhsColumnNames;
    this.rightHandSideRequired = rightHandSideRequired;
    this.joinedPropertyType = joinedPropertyType;
    if ( StringHelper.isEmpty( lhsPropertyName ) ) {
        throw new IllegalArgumentException( "Incoming 'lhsPropertyName' parameter was empty" );
    }
}
项目:lams    文件:DynamicBatchingCollectionInitializerBuilder.java   
public DynamicBatchingCollectionLoader(
        QueryableCollection collectionPersister,
        SessionFactoryImplementor factory,
        LoadQueryInfluencers influencers) {
    super( collectionPersister, factory, influencers );

    JoinWalker walker = buildJoinWalker( collectionPersister, factory, influencers );
    initFromWalker( walker );
    this.sqlTemplate = walker.getSQLString();
    this.alias = StringHelper.generateAlias( collectionPersister.getRole(), 0 );
    postInstantiate();

    if ( LOG.isDebugEnabled() ) {
        LOG.debugf(
                "SQL-template for dynamic collection [%s] batch-fetching : %s",
                collectionPersister.getRole(),
                sqlTemplate
        );
    }
}
项目:lams    文件:PropertyBinder.java   
/**
 * Returns the value generation strategy for the given property, if any.
 */
private ValueGeneration getValueGenerationFromAnnotations(XProperty property) {
    AnnotationValueGeneration<?> valueGeneration = null;

    for ( Annotation annotation : property.getAnnotations() ) {
        AnnotationValueGeneration<?> candidate = getValueGenerationFromAnnotation( property, annotation );

        if ( candidate != null ) {
            if ( valueGeneration != null ) {
                throw new AnnotationException(
                        "Only one generator annotation is allowed:" + StringHelper.qualify(
                                holder.getPath(),
                                name
                        )
                );
            }
            else {
                valueGeneration = candidate;
            }
        }
    }

    return valueGeneration;
}
项目:lams    文件:SqlExceptionHelper.java   
/**
 * Log the given (and any nested) exception.
 *
 * @param sqlException The exception to log
 * @param message The message text to use as a preamble.
 */
public void logExceptions(SQLException sqlException, String message) {
    if ( LOG.isEnabled( Level.ERROR ) ) {
        if ( LOG.isDebugEnabled() ) {
            message = StringHelper.isNotEmpty( message ) ? message : DEFAULT_EXCEPTION_MSG;
            LOG.debug( message, sqlException );
        }
        final boolean warnEnabled = LOG.isEnabled( Level.WARN );
        while ( sqlException != null ) {
            if ( warnEnabled ) {
                LOG.warn( "SQL Error: " + sqlException.getErrorCode() + ", SQLState: " + sqlException.getSQLState() );
            }
            LOG.error( sqlException.getMessage() );
            sqlException = sqlException.getNextException();
        }
    }
}
项目:lams    文件:SingleLineSqlCommandExtractor.java   
@Override
public String[] extractCommands(Reader reader) {
    BufferedReader bufferedReader = new BufferedReader( reader );
    List<String> statementList = new LinkedList<String>();
    try {
        for ( String sql = bufferedReader.readLine(); sql != null; sql = bufferedReader.readLine() ) {
            String trimmedSql = sql.trim();
            if ( StringHelper.isEmpty( trimmedSql ) || isComment( trimmedSql ) ) {
                continue;
            }
            if ( trimmedSql.endsWith( ";" ) ) {
                trimmedSql = trimmedSql.substring( 0, trimmedSql.length() - 1 );
            }
            statementList.add( trimmedSql );
        }
        return statementList.toArray( new String[statementList.size()] );
    }
    catch ( IOException e ) {
        throw new ImportScriptException( "Error during import script parsing.", e );
    }
}
项目:lams    文件:Cache71Dialect.java   
@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();
}
项目:lams    文件: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.debugf( "Import: %s -> %s", rename, className );
    mappings.addImport( className, rename );
}
项目:lams    文件:ConstructorNode.java   
private String formatMissingContructorExceptionMessage(String className) {
    String[] params = new String[constructorArgumentTypes.length];
    for ( int j = 0; j < constructorArgumentTypes.length; j++ ) {
        params[j] = constructorArgumentTypes[j] instanceof PrimitiveType
                ? ( (PrimitiveType) constructorArgumentTypes[j] ).getPrimitiveClass().getName()
                : constructorArgumentTypes[j].getReturnedClass().getName();
    }
    String formattedList = params.length == 0 ? "no arguments constructor" : StringHelper.join( ", ", params );
    return String.format(
            "Unable to locate appropriate constructor on class [%s]. Expected arguments are: %s",
            className, formattedList
    );
}
项目:lams    文件: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" ) );
//      }
    }
项目:lams    文件:AbstractLoadPlanBuildingAssociationVisitationStrategy.java   
@Override
public void startingCollection(CollectionDefinition collectionDefinition) {
    // see if the EntityDefinition is a root...
    final boolean isRoot = fetchSourceStack.isEmpty();
    if ( ! isRoot ) {
        // if not, this call should represent a fetch which should have been handled in #startingAttribute
        return;
    }

    log.tracef(
            "%s Starting root collection : %s",
            StringHelper.repeat( ">>", fetchSourceStack.size() ),
            collectionDefinition.getCollectionPersister().getRole()
    );

    // if we get here, it is a root
    if ( ! supportsRootCollectionReturns() ) {
        throw new HibernateException( "This strategy does not support root collection returns" );
    }

    final CollectionReturn collectionReturn = new CollectionReturnImpl( collectionDefinition, querySpaces );
    pushToCollectionStack( collectionReturn );
    addRootReturn( collectionReturn );

    associationKeyRegistered(
            new AssociationKey(
                    ( (Joinable) collectionDefinition.getCollectionPersister() ).getTableName(),
                    ( (Joinable) collectionDefinition.getCollectionPersister() ).getKeyColumnNames()
            )
    );
}
项目:lams    文件:BasicFormatterImpl.java   
public FormatProcess(String sql) {
    tokens = new StringTokenizer(
            sql,
            "()+*/-=<>'`\"[]," + StringHelper.WHITESPACE,
            true
    );
}
项目:lams    文件:Configuration.java   
private List<MetadataSourceType> determineMetadataSourcePrecedence() {
    if ( metadataSourcePrecedence.isEmpty()
            && StringHelper.isNotEmpty( getProperties().getProperty( ARTEFACT_PROCESSING_ORDER ) ) ) {
        metadataSourcePrecedence = parsePrecedence( getProperties().getProperty( ARTEFACT_PROCESSING_ORDER ) );
    }
    if ( metadataSourcePrecedence.isEmpty() ) {
        metadataSourcePrecedence = Arrays.asList( DEFAULT_ARTEFACT_PROCESSING_ORDER );
    }
    metadataSourcePrecedence = Collections.unmodifiableList( metadataSourcePrecedence );

    return metadataSourcePrecedence;
}
项目:lams    文件:DefaultEntityAliases.java   
@Override
public String[][] getSuffixedPropertyAliases(Loadable persister) {
    final int size = persister.getPropertyNames().length;
    final String[][] suffixedPropertyAliases = new String[size][];
    for ( int j = 0; j < size; j++ ) {
        suffixedPropertyAliases[j] = getUserProvidedAliases(
                persister.getPropertyNames()[j],
                getPropertyAliases( persister, j )
        );
        suffixedPropertyAliases[j] = StringHelper.unquote( suffixedPropertyAliases[j], persister.getFactory().getDialect() );
        intern( suffixedPropertyAliases[j] );
    }
    return suffixedPropertyAliases;
}
项目:lams    文件: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
            );
}
项目:lams    文件:PersistentClass.java   
private Property getProperty(String propertyName, Iterator iterator) throws MappingException {
    if(iterator.hasNext()) {
        String root = StringHelper.root(propertyName);
        while ( iterator.hasNext() ) {
            Property prop = (Property) iterator.next();
            if ( prop.getName().equals( root ) ) {
                return prop;
            }
        }
    }
    throw new MappingException( "property [" + propertyName + "] not found on entity [" + getEntityName() + "]" );
}
项目:lams    文件:ConfigurationHelper.java   
/**
 * Handles interpolation processing for a single property.
 *
 * @param property The property value to be processed for interpolation.
 * @return The (possibly) interpolated property value.
 */
public static String resolvePlaceHolder(String property) {
    if ( property.indexOf( PLACEHOLDER_START ) < 0 ) {
        return property;
    }
    StringBuilder buff = new StringBuilder();
    char[] chars = property.toCharArray();
    for ( int pos = 0; pos < chars.length; pos++ ) {
        if ( chars[pos] == '$' ) {
            // peek ahead
            if ( chars[pos+1] == '{' ) {
                // we have a placeholder, spin forward till we find the end
                String systemPropertyName = "";
                int x = pos + 2;
                for (  ; x < chars.length && chars[x] != '}'; x++ ) {
                    systemPropertyName += chars[x];
                    // if we reach the end of the string w/o finding the
                    // matching end, that is an exception
                    if ( x == chars.length - 1 ) {
                        throw new IllegalArgumentException( "unmatched placeholder start [" + property + "]" );
                    }
                }
                String systemProperty = extractFromSystem( systemPropertyName );
                buff.append( systemProperty == null ? "" : systemProperty );
                pos = x + 1;
                // make sure spinning forward did not put us past the end of the buffer...
                if ( pos >= chars.length ) {
                    break;
                }
            }
        }
        buff.append( chars[pos] );
    }
    String rtn = buff.toString();
    return StringHelper.isEmpty( rtn ) ? null : rtn;
}
项目:lams    文件:PropertyProjection.java   
@Override
public String toGroupSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
    if ( !grouped ) {
        return super.toGroupSqlString( criteria, criteriaQuery );
    }
    else {
        return StringHelper.join( ", ", criteriaQuery.getColumns( propertyName, criteria ) );
    }
}
项目:lams    文件:JpaNamingStrategyDelegate.java   
@Override
public String determineImplicitEntityAssociationJoinColumnName(
        String propertyEntityName, String propertyJpaEntityName, String propertyTableName, String referencedColumnName, String referencingPropertyName) {
    // JPA states we should use the following as default:
    //      "The concatenation of the following: the name of the referencing relationship
    //      property or field of the referencing entity or embeddable class; "_"; the name
    //      of the referenced primary key column. If there is no such referencing relationship
    //      property or field in the entity, or if the join is for an element collection, the
    //      join column name is formed as the concatenation of the following: the name of the
    //      entity; "_"; the name of the referenced primary key column
    // The part referring to an entity collection can be disregarded here since, determination of
    // an element collection foreign key column name is covered  by #entityAssociationJoinTableName().
    //
    // For a unidirectional association:
    //      {PROPERTY_ENTITY_NAME}_{REFERENCED_COLUMN_NAME}
    // For a bidirectional association:
    //      {REFERENCING_PROPERTY_NAME}_{REFERENCED_COLUMN_NAME}
    final String header;
    if ( referencingPropertyName == null ) {
        // This is a unidirectional association.
        header = determineEntityNameToUse( propertyEntityName, propertyJpaEntityName );
    }
    else {
        // This is a bidirectional association.
        header = StringHelper.unqualify( referencingPropertyName );
    }
    if ( header == null ) {
        throw new AssertionFailure( "propertyJpaEntityName and referencingPropertyName cannot both be empty." );
    }
    return toPhysicalColumnName( header + "_" + referencedColumnName );
}
项目:lams    文件:LoadQueryJoinAndFetchProcessor.java   
private void addJoins(
        Join join,
        JoinFragment joinFragment,
        Joinable joinable) {

    final String rhsTableAlias = aliasResolutionContext.resolveSqlTableAliasFromQuerySpaceUid(
            join.getRightHandSide().getUid()
    );
    if ( StringHelper.isEmpty( rhsTableAlias ) ) {
        throw new IllegalStateException( "Join's RHS table alias cannot be empty" );
    }

    final String lhsTableAlias = aliasResolutionContext.resolveSqlTableAliasFromQuerySpaceUid(
            join.getLeftHandSide().getUid()
    );
    if ( lhsTableAlias == null ) {
        throw new IllegalStateException( "QuerySpace with that UID was not yet registered in the AliasResolutionContext" );
    }

    // add join fragments from the collection table -> element entity table ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    final String additionalJoinConditions = resolveAdditionalJoinCondition(
            rhsTableAlias,
            join.getAnyAdditionalJoinConditions( rhsTableAlias ),
            joinable,
            getJoinedAssociationTypeOrNull( join )
    );

    joinFragment.addJoin(
            joinable.getTableName(),
            rhsTableAlias,
            join.resolveAliasedLeftHandSideJoinConditionColumns( lhsTableAlias ),
            join.resolveNonAliasedRightHandSideJoinConditionColumns(),
            join.isRightHandSideRequired() ? JoinType.INNER_JOIN : JoinType.LEFT_OUTER_JOIN,
            additionalJoinConditions
    );
    joinFragment.addJoins(
            joinable.fromJoinFragment( rhsTableAlias, false, true ),
            joinable.whereJoinFragment( rhsTableAlias, false, true )
    );
}
项目:lams    文件:HbmNamingStrategyDelegate.java   
@Override
public String determineImplicitElementCollectionTableName(
        String ownerEntityName,
        String ownerJpaEntityName,
        String ownerEntityTable,
        String propertyPath) {
    return ownerEntityTable
            + '_'
            + StringHelper.unqualify( propertyPath );
}
项目:lams    文件:JavaConstantNode.java   
@Override
public void setText(String s) {
    // for some reason the antlr.CommonAST initialization routines force
    // this method to get called twice.  The first time with an empty string
    if ( StringHelper.isNotEmpty( s ) ) {
        constantExpression = s;
        constantValue = ReflectHelper.getConstantValue( s );
        heuristicType = factory.getTypeResolver().heuristicType( constantValue.getClass().getName() );
        super.setText( s );
    }
}
项目:lams    文件:BinderHelper.java   
public static String getRelativePath(PropertyHolder propertyHolder, String propertyName) {
    if ( propertyHolder == null ) return propertyName;
    String path = propertyHolder.getPath();
    String entityName = propertyHolder.getPersistentClass().getEntityName();
    if ( path.length() == entityName.length() ) {
        return propertyName;
    }
    else {
        return StringHelper.qualify( path.substring( entityName.length() + 1 ), propertyName );
    }
}
项目:lams    文件:BinderHelper.java   
public static Map<String,String> toAliasTableMap(SqlFragmentAlias[] aliases){
        Map<String,String> ret = new HashMap<String,String>();
        for (int i = 0; i < aliases.length; i++){
            if (StringHelper.isNotEmpty(aliases[i].table())){
                ret.put(aliases[i].alias(), aliases[i].table());
}
        }
        return ret;
    }
项目:lams    文件:IdentifierProjection.java   
@Override
public String toGroupSqlString(Criteria criteria, CriteriaQuery criteriaQuery) {
    if ( !grouped ) {
        return super.toGroupSqlString( criteria, criteriaQuery );
    }
    else {
        return StringHelper.join( ", ", criteriaQuery.getIdentifierColumns( criteria ) );
    }
}
项目:lams    文件:LoadQueryJoinAndFetchProcessor.java   
private void renderManyToManyJoin(
        Join join,
        JoinFragment joinFragment) {

    // for many-to-many we have 3 table aliases.  By way of example, consider a normal m-n: User<->Role
    // where User is the FetchOwner and Role (User.roles) is the Fetch.  We'd have:
    //      1) the owner's table : user - in terms of rendering the joins (not the fetch select fragments), the
    //          lhs table alias is only needed to qualify the lhs join columns, but we already have the qualified
    //          columns here (aliasedLhsColumnNames)
    //final String ownerTableAlias = ...;
    //      2) the m-n table : user_role
    //      3) the element table : role
    final EntityPersister entityPersister = ( (EntityQuerySpace) join.getRightHandSide() ).getEntityPersister();
    final String entityTableAlias = aliasResolutionContext.resolveSqlTableAliasFromQuerySpaceUid(
        join.getRightHandSide().getUid()
    );

    if ( StringHelper.isEmpty( entityTableAlias ) ) {
        throw new IllegalStateException( "Collection element (many-to-many) table alias cannot be empty" );
    }
    if ( JoinDefinedByMetadata.class.isInstance( join ) &&
            CollectionPropertyNames.COLLECTION_ELEMENTS.equals( ( (JoinDefinedByMetadata) join ).getJoinedPropertyName() ) ) {
        final CollectionQuerySpace leftHandSide = (CollectionQuerySpace) join.getLeftHandSide();
        final CollectionPersister persister = leftHandSide.getCollectionPersister();
        final String manyToManyFilter = persister.getManyToManyFilterFragment(
                entityTableAlias,
                buildingParameters.getQueryInfluencers().getEnabledFilters()
        );
        joinFragment.addCondition( manyToManyFilter );
    }

    addJoins(
            join,
            joinFragment,
            (Joinable) entityPersister
    );
}
项目:lams    文件:BasicCollectionLoadQueryDetails.java   
@Override
protected void applyRootReturnOrderByFragments(SelectStatementBuilder selectStatementBuilder) {
    final String manyToManyOrdering = getQueryableCollection().getManyToManyOrderByString(
            getCollectionReferenceAliases().getElementTableAlias()
    );
    if ( StringHelper.isNotEmpty( manyToManyOrdering ) ) {
        selectStatementBuilder.appendOrderByFragment( manyToManyOrdering );
    }
    super.applyRootReturnOrderByFragments( selectStatementBuilder );
}
项目:lams    文件:EJB3NamingStrategy.java   
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 );
}
项目:lams    文件:Index.java   
public static String buildSqlCreateIndexString(
        Dialect dialect,
        String name,
        TableSpecification table,
        Iterable<Column> columns,
        boolean unique
) {
    StringBuilder buf = new StringBuilder( "create" )
            .append( unique ?
                    " unique" :
                    "" )
            .append( " index " )
            .append( dialect.qualifyIndexName() ?
                    name :
                    StringHelper.unqualify( name ) )
            .append( " on " )
            .append( table.getQualifiedName( dialect ) )
            .append( " (" );
    boolean first = true;
    for ( Column column : columns ) {
        if ( first ) {
            first = false;
        }
        else {
            buf.append( ", " );
        }
        buf.append( ( column.getColumnName().encloseInQuotesIfQuoted( dialect ) ) );
    }
    buf.append( ")" );
    return buf.toString();
}
项目:lams    文件:SubselectFetch.java   
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;
}
项目:lams    文件:Index.java   
public String sqlDropString(Dialect dialect, String defaultCatalog, String defaultSchema) {
    return "drop index " +
            StringHelper.qualify(
                    table.getQualifiedName( dialect, defaultCatalog, defaultSchema ),
                    name
            );
}