Java 类org.hibernate.mapping.IndexedCollection 实例源码

项目:lams    文件:CollectionSecondPass.java   
public void doSecondPass(java.util.Map persistentClasses)
        throws MappingException {
    final boolean debugEnabled = LOG.isDebugEnabled();
    if ( debugEnabled ) {
        LOG.debugf( "Second pass for collection: %s", collection.getRole() );
    }

    secondPass( persistentClasses, localInheritedMetas ); // using local since the inheritedMetas at this point is not the correct map since it is always the empty map
    collection.createAllKeys();

    if ( debugEnabled ) {
        String msg = "Mapped collection key: " + columns( collection.getKey() );
        if ( collection.isIndexed() )
            msg += ", index: " + columns( ( (IndexedCollection) collection ).getIndex() );
        if ( collection.isOneToMany() ) {
            msg += ", one-to-many: "
                + ( (OneToMany) collection.getElement() ).getReferencedEntityName();
        }
        else {
            msg += ", element: " + columns( collection.getElement() );
        }
        LOG.debug( msg );
    }
}
项目:cacheonix-core    文件:CollectionSecondPass.java   
public void doSecondPass(java.util.Map persistentClasses)
        throws MappingException {
    if ( log.isDebugEnabled() )
        log.debug( "Second pass for collection: " + collection.getRole() );

    secondPass( persistentClasses, localInheritedMetas ); // using local since the inheritedMetas at this point is not the correct map since it is always the empty map
    collection.createAllKeys();

    if ( log.isDebugEnabled() ) {
        String msg = "Mapped collection key: " + columns( collection.getKey() );
        if ( collection.isIndexed() )
            msg += ", index: " + columns( ( (IndexedCollection) collection ).getIndex() );
        if ( collection.isOneToMany() ) {
            msg += ", one-to-many: "
                + ( (OneToMany) collection.getElement() ).getReferencedEntityName();
        }
        else {
            msg += ", element: " + columns( collection.getElement() );
        }
        log.debug( msg );
    }
}
项目:lams    文件:HbmBinder.java   
/**
 * Called for Lists, arrays, primitive arrays
 */
public static void bindListSecondPass(Element node, List list, java.util.Map classes,
        Mappings mappings, java.util.Map inheritedMetas) throws MappingException {

    bindCollectionSecondPass( node, list, classes, mappings, inheritedMetas );

    Element subnode = node.element( "list-index" );
    if ( subnode == null ) subnode = node.element( "index" );
    SimpleValue iv = new SimpleValue( mappings, list.getCollectionTable() );
    bindSimpleValue(
            subnode,
            iv,
            list.isOneToMany(),
            IndexedCollection.DEFAULT_INDEX_COLUMN_NAME,
            mappings
    );
    iv.setTypeName( "integer" );
    list.setIndex( iv );
    String baseIndex = subnode.attributeValue( "base" );
    if ( baseIndex != null ) list.setBaseIndex( Integer.parseInt( baseIndex ) );
    list.setIndexNodeName( subnode.attributeValue("node") );

    if ( list.isOneToMany() && !list.getKey().isNullable() && !list.isInverse() ) {
        String entityName = ( (OneToMany) list.getElement() ).getReferencedEntityName();
        PersistentClass referenced = mappings.getClass( entityName );
        IndexBackref ib = new IndexBackref();
        ib.setName( '_' + list.getOwnerEntityName() + "." + node.attributeValue( "name" ) + "IndexBackref" );
        ib.setUpdateable( false );
        ib.setSelectable( false );
        ib.setCollectionRole( list.getRole() );
        ib.setEntityName( list.getOwner().getEntityName() );
        ib.setValue( list.getIndex() );
        // ( (Column) ( (SimpleValue) ic.getIndex() ).getColumnIterator().next()
        // ).setNullable(false);
        referenced.addProperty( ib );
    }
}
项目:lams    文件:CollectionPropertyHolder.java   
private Class determineKeyClass(XClass keyXClass) {
    if ( keyXClass != null ) {
        try {
            return getMappings().getReflectionManager().toClass( keyXClass );
        }
        catch (Exception e) {
            log.debugf(
                    "Unable to resolve XClass [%s] to Class for collection key [%s]",
                    keyXClass.getName(),
                    collection.getRole()
            );
        }
    }

    final IndexedCollection indexedCollection = (IndexedCollection) collection;
    if ( indexedCollection.getIndex() != null ) {
        if ( indexedCollection.getIndex().getType() != null ) {
            return indexedCollection.getIndex().getType().getReturnedClass();
        }
    }

    // currently this is called from paths where the element type really should be known,
    // so log the fact that we could not resolve the collection element info
    log.debugf(
            "Unable to resolve key information for collection [%s]",
            collection.getRole()
    );
    return null;
}
项目:cacheonix-core    文件:HbmBinder.java   
/**
 * Called for Lists, arrays, primitive arrays
 */
public static void bindListSecondPass(Element node, List list, java.util.Map classes,
        Mappings mappings, java.util.Map inheritedMetas) throws MappingException {

    bindCollectionSecondPass( node, list, classes, mappings, inheritedMetas );

    Element subnode = node.element( "list-index" );
    if ( subnode == null ) subnode = node.element( "index" );
    SimpleValue iv = new SimpleValue( list.getCollectionTable() );
    bindSimpleValue(
            subnode,
            iv,
            list.isOneToMany(),
            IndexedCollection.DEFAULT_INDEX_COLUMN_NAME,
            mappings
        );
    iv.setTypeName( "integer" );
    list.setIndex( iv );
    String baseIndex = subnode.attributeValue( "base" );
    if ( baseIndex != null ) list.setBaseIndex( Integer.parseInt( baseIndex ) );
    list.setIndexNodeName( subnode.attributeValue("node") );

    if ( list.isOneToMany() && !list.getKey().isNullable() && !list.isInverse() ) {
        String entityName = ( (OneToMany) list.getElement() ).getReferencedEntityName();
        PersistentClass referenced = mappings.getClass( entityName );
        IndexBackref ib = new IndexBackref();
        ib.setName( '_' + node.attributeValue( "name" ) + "IndexBackref" );
        ib.setUpdateable( false );
        ib.setSelectable( false );
        ib.setCollectionRole( list.getRole() );
        ib.setEntityName( list.getOwner().getEntityName() );
        ib.setValue( list.getIndex() );
        // ( (Column) ( (SimpleValue) ic.getIndex() ).getColumnIterator().next()
        // ).setNullable(false);
        referenced.addProperty( ib );
    }
}
项目:hibernate-semantic-query    文件:CollectionPersisterImpl.java   
public CollectionPersisterImpl(
            Collection collectionBinding,
            ManagedTypeImplementor source,
            String localName,
            CollectionRegionAccessStrategy collectionCaching,
            PersisterCreationContext creationContext) {
        super( source, localName, PropertyAccess.DUMMY );
        this.source = source;
        this.localName = localName;
        this.role = source.getNavigableName() + '.' + this.localName;
        this.collectionClassification = PersisterHelper.interpretCollectionClassification( collectionBinding );
        this.foreignKeyDescriptor = new CollectionKey( this );

        this.typeConfiguration = creationContext.getTypeConfiguration();

        this.collectionType = new CollectionTypeImpl(
                role,
                resolveCollectionJtd( creationContext, collectionClassification ),
                null,
                null
        );

        if ( collectionBinding instanceof IndexedCollection ) {
            final Value indexValueMapping = ( (IndexedCollection) collectionBinding ).getIndex();
            if ( indexValueMapping instanceof SimpleValue ) {
                final SimpleValue simpleIndexValueMapping = (SimpleValue) indexValueMapping;
//              indexAttributeConverter = simpleIndexValueMapping.getAttributeConverterDescriptor().getAttributeConverter();
            }
        }

        final Value elementValueMapping = collectionBinding.getElement();
        if ( elementValueMapping instanceof SimpleValue ) {
            final SimpleValue simpleElementValueMapping = (SimpleValue) elementValueMapping;
//          elementAttributeConverter = simpleElementValueMapping.getAttributeConverterDescriptor().getAttributeConverter();
        }
    }