当前位置: 首页>>代码示例>>Java>>正文


Java Collection类代码示例

本文整理汇总了Java中org.hibernate.mapping.Collection的典型用法代码示例。如果您正苦于以下问题:Java Collection类的具体用法?Java Collection怎么用?Java Collection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Collection类属于org.hibernate.mapping包,在下文中一共展示了Collection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: bindCollectionSecondPass

import org.hibernate.mapping.Collection; //导入依赖的package包/类
private static void bindCollectionSecondPass(
		Collection collValue,
		PersistentClass collectionEntity,
		Ejb3JoinColumn[] joinColumns,
		boolean cascadeDeleteEnabled,
		XProperty property,
		Mappings mappings) {
	try {
		BinderHelper.createSyntheticPropertyReference(
				joinColumns, collValue.getOwner(), collectionEntity, collValue, false, mappings
		);
	}
	catch (AnnotationException ex) {
		throw new AnnotationException( "Unable to map collection " + collectionEntity.getClassName() + "." + property.getName(), ex );
	}
	SimpleValue key = buildCollectionKey( collValue, joinColumns, cascadeDeleteEnabled, property, mappings );
	if ( property.isAnnotationPresent( ElementCollection.class ) && joinColumns.length > 0 ) {
		joinColumns[0].setJPA2ElementCollection( true );
	}
	TableBinder.bindFk( collValue.getOwner(), collectionEntity, joinColumns, key, false, mappings );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:CollectionBinder.java

示例2: contribute

import org.hibernate.mapping.Collection; //导入依赖的package包/类
@Override
public void contribute(InFlightMetadataCollector metadataCollector, IndexView jandexIndex) {
    MetadataBuildingOptions options = metadataCollector.getMetadataBuildingOptions();
    ClassLoaderService classLoaderService = options.getServiceRegistry().getService(ClassLoaderService.class);

    final ClassLoaderAccess classLoaderAccess = new ClassLoaderAccessImpl(
            options.getTempClassLoader(),
            classLoaderService
    );

    this.metadataBuildingContext = new MetadataBuildingContextRootImpl(
            options,
            classLoaderAccess,
            metadataCollector
    );

        java.util.Collection<PersistentEntity> persistentEntities = hibernateMappingContext.getPersistentEntities();
    for (PersistentEntity persistentEntity : persistentEntities) {
        if(!persistentEntity.getJavaClass().isAnnotationPresent(Entity.class)) {
            if(ConnectionSourcesSupport.usesConnectionSource(persistentEntity, dataSourceName) && persistentEntity.isRoot()) {
                bindRoot((HibernatePersistentEntity) persistentEntity, metadataCollector, sessionFactoryName);
            }
        }
    }
}
 
开发者ID:grails,项目名称:gorm-hibernate5,代码行数:26,代码来源:GrailsDomainBinder.java

示例3: createPrimaryKeyValue

import org.hibernate.mapping.Collection; //导入依赖的package包/类
/**
 * Creates the DependentValue object that forms a primary key reference for the collection.
 *
 * @param mappings
 * @param property          The grails property
 * @param collection        The collection object
 * @param persistentClasses
 * @return The DependantValue (key)
 */
protected DependantValue createPrimaryKeyValue(InFlightMetadataCollector mappings, PersistentProperty property,
                                               Collection collection, Map<?, ?> persistentClasses) {
    KeyValue keyValue;
    DependantValue key;
    String propertyRef = collection.getReferencedPropertyName();
    // this is to support mapping by a property
    if (propertyRef == null) {
        keyValue = collection.getOwner().getIdentifier();
    } else {
        keyValue = (KeyValue) collection.getOwner().getProperty(propertyRef).getValue();
    }

    if (LOG.isDebugEnabled())
        LOG.debug("[GrailsDomainBinder] creating dependant key value  to table [" + keyValue.getTable().getName() + "]");

    key = new DependantValue(mappings, collection.getCollectionTable(), keyValue);

    key.setTypeName(null);
    // make nullable and non-updateable
    key.setNullable(true);
    key.setUpdateable(false);
    return key;
}
 
开发者ID:grails,项目名称:gorm-hibernate5,代码行数:33,代码来源:GrailsDomainBinder.java

示例4: bindUnidirectionalOneToMany

import org.hibernate.mapping.Collection; //导入依赖的package包/类
/**
 * Binds a unidirectional one-to-many creating a psuedo back reference property in the process.
 *
 * @param property
 * @param mappings
 * @param collection
 */
protected void bindUnidirectionalOneToMany(org.grails.datastore.mapping.model.types.OneToMany property, InFlightMetadataCollector mappings, Collection collection) {
    Value v = collection.getElement();
    v.createForeignKey();
    String entityName;
    if (v instanceof ManyToOne) {
        ManyToOne manyToOne = (ManyToOne) v;

        entityName = manyToOne.getReferencedEntityName();
    } else {
        entityName = ((OneToMany) v).getReferencedEntityName();
    }
    collection.setInverse(false);
    PersistentClass referenced = mappings.getEntityBinding(entityName);
    Backref prop = new Backref();
    PersistentEntity owner = property.getOwner();
    prop.setEntityName(owner.getName());
    prop.setName(UNDERSCORE + addUnderscore(owner.getJavaClass().getSimpleName(), property.getName()) + "Backref");
    prop.setUpdateable(false);
    prop.setInsertable(true);
    prop.setCollectionRole(collection.getRole());
    prop.setValue(collection.getKey());
    prop.setOptional(true);

    referenced.addProperty(prop);
}
 
开发者ID:grails,项目名称:gorm-hibernate5,代码行数:33,代码来源:GrailsDomainBinder.java

示例5: buildPluralAttribute

import org.hibernate.mapping.Collection; //导入依赖的package包/类
public OrmAttribute buildPluralAttribute(
		PersisterCreationContext creationContext,
		Collection collectionBinding,
		OrmNavigableSource source,
		String propertyName) {
	// todo : resolve cache access
	final CollectionRegionAccessStrategy cachingAccess = null;

	// need PersisterCreationContext - we should always have access to that when building persisters, through finalized initialization
	final CollectionPersister collectionPersister = creationContext.getPersisterFactory().createCollectionPersister(
			collectionBinding,
			(ManagedTypeImplementor) source,
			propertyName,
			cachingAccess,
			creationContext
	);
	creationContext.registerCollectionPersister( collectionPersister );
	return collectionPersister;
}
 
开发者ID:hibernate,项目名称:hibernate-semantic-query,代码行数:20,代码来源:PersisterHelper.java

示例6: convertCollection

import org.hibernate.mapping.Collection; //导入依赖的package包/类
private static CollectionType convertCollection(
		PersisterCreationContext creationContext,
		ManagedTypeImplementor source,
		String navigableName,
		Collection collectionValue,
		TypeConfiguration typeConfiguration) {
	final String roleName = source.getRolePrefix() + navigableName;

	CollectionPersister<?, ?, ?> collectionPersister = typeConfiguration.findCollectionPersister( roleName );

	if ( collectionPersister == null ) {
		collectionPersister = creationContext.getPersisterFactory().createCollectionPersister(
				collectionValue,
				source,
				navigableName,
				null,
				creationContext
		);
	}

	return collectionPersister.getOrmType();
}
 
开发者ID:hibernate,项目名称:hibernate-semantic-query,代码行数:23,代码来源:OrmTypeHelper.java

示例7: listTables

import org.hibernate.mapping.Collection; //导入依赖的package包/类
private List<String> listTables() {

		List<String> results = new ArrayList<String>();

		Iterator<PersistentClass> iterator1 = configuration.getClassMappings();
		while (iterator1.hasNext()) {
			results.add(iterator1.next().getTable().getName());
		}

		Iterator<?> iterator2 = configuration.getCollectionMappings();
		while (iterator2.hasNext()) {
			results.add(((Collection) iterator2.next()).getTable().getName());
		}

		return results;

	}
 
开发者ID:andreluiznsilva,项目名称:hibernate-conventions,代码行数:18,代码来源:DDLConventions.java

示例8: validate

import org.hibernate.mapping.Collection; //导入依赖的package包/类
private void validate() throws MappingException {
	Iterator iter = classes.values().iterator();
	while ( iter.hasNext() ) {
		( (PersistentClass) iter.next() ).validate( mapping );
	}
	iter = collections.values().iterator();
	while ( iter.hasNext() ) {
		( (Collection) iter.next() ).validate( mapping );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:Configuration.java

示例9: applyCollectionCacheConcurrencyStrategy

import org.hibernate.mapping.Collection; //导入依赖的package包/类
private void applyCollectionCacheConcurrencyStrategy(CacheHolder holder) {
	Collection collection = getCollectionMapping( holder.role );
	if ( collection == null ) {
		throw new MappingException( "Cannot cache an unknown collection: " + holder.role );
	}
	collection.setCacheConcurrencyStrategy( holder.usage );
	collection.setCacheRegionName( holder.region );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:Configuration.java

示例10: getAttributeConverters

import org.hibernate.mapping.Collection; //导入依赖的package包/类
@Override
public java.util.Collection<AttributeConverterDefinition> getAttributeConverters() {
	if ( attributeConverterDefinitionsByClass == null ) {
		return Collections.emptyList();
	}
	return attributeConverterDefinitionsByClass.values();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:Configuration.java

示例11: CollectionPropertyHolder

import org.hibernate.mapping.Collection; //导入依赖的package包/类
public CollectionPropertyHolder(
		Collection collection,
		String path,
		XClass clazzToProcess,
		XProperty property,
		PropertyHolder parentPropertyHolder,
		Mappings mappings) {
	super( path, parentPropertyHolder, clazzToProcess, mappings );
	this.collection = collection;
	setCurrentProperty( property );

	this.elementAttributeConversionInfoMap = new HashMap<String, AttributeConversionInfo>();
	this.keyAttributeConversionInfoMap = new HashMap<String, AttributeConversionInfo>();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:CollectionPropertyHolder.java

示例12: buildPropertyHolder

import org.hibernate.mapping.Collection; //导入依赖的package包/类
/**
 * buid a property holder on top of a collection
 */
public static CollectionPropertyHolder buildPropertyHolder(
		Collection collection,
		String path,
		XClass clazzToProcess,
		XProperty property,
		PropertyHolder parentPropertyHolder,
		Mappings mappings) {
	return new CollectionPropertyHolder(
			collection, path, clazzToProcess, property, parentPropertyHolder, mappings
	);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:PropertyHolderBuilder.java

示例13: checkFilterConditions

import org.hibernate.mapping.Collection; //导入依赖的package包/类
private static void checkFilterConditions(Collection collValue) {
	//for now it can't happen, but sometime soon...
	if ( ( collValue.getFilters().size() != 0 || StringHelper.isNotEmpty( collValue.getWhere() ) ) &&
			collValue.getFetchMode() == FetchMode.JOIN &&
			!( collValue.getElement() instanceof SimpleValue ) && //SimpleValue (CollectionOfElements) are always SELECT but it does not matter
			collValue.getElement().getFetchMode() != FetchMode.JOIN ) {
		throw new MappingException(
				"@ManyToMany or @CollectionOfElements defining filter or where without join fetching "
						+ "not valid within collection using join fetching[" + collValue.getRole() + "]"
		);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:CollectionBinder.java

示例14: bindIndex

import org.hibernate.mapping.Collection; //导入依赖的package包/类
private void bindIndex(final Mappings mappings) {
	if ( !indexColumn.isImplicit() ) {
		PropertyHolder valueHolder = PropertyHolderBuilder.buildPropertyHolder(
				this.collection,
				StringHelper.qualify( this.collection.getRole(), "key" ),
				null,
				null, propertyHolder, mappings
		);
		List list = (List) this.collection;
		if ( !list.isOneToMany() ) indexColumn.forceNotNull();
		indexColumn.setPropertyHolder( valueHolder );
		SimpleValueBinder value = new SimpleValueBinder();
		value.setColumns( new Ejb3Column[] { indexColumn } );
		value.setExplicitType( "integer" );
		value.setMappings( mappings );
		SimpleValue indexValue = value.make();
		indexColumn.linkWithValue( indexValue );
		list.setIndex( indexValue );
		list.setBaseIndex( indexColumn.getBase() );
		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( '_' + propertyName + "IndexBackref" );
			ib.setUpdateable( false );
			ib.setSelectable( false );
			ib.setCollectionRole( list.getRole() );
			ib.setEntityName( list.getOwner().getEntityName() );
			ib.setValue( list.getIndex() );
			referenced.addProperty( ib );
		}
	}
	else {
		Collection coll = this.collection;
		throw new AnnotationException(
				"List/array has to be annotated with an @OrderColumn (or @IndexColumn): "
						+ coll.getRole()
		);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:41,代码来源:ListBinder.java

示例15: createCollectionPersister

import org.hibernate.mapping.Collection; //导入依赖的package包/类
@Override
@SuppressWarnings( {"unchecked"})
public CollectionPersister createCollectionPersister(
		Configuration cfg,
		Collection collectionMetadata,
		CollectionRegionAccessStrategy cacheAccessStrategy,
		SessionFactoryImplementor factory) throws HibernateException {
	Class<? extends CollectionPersister> persisterClass = collectionMetadata.getCollectionPersisterClass();
	if ( persisterClass == null ) {
		persisterClass = serviceRegistry.getService( PersisterClassResolver.class ).getCollectionPersisterClass( collectionMetadata );
	}

	return create( persisterClass, COLLECTION_PERSISTER_CONSTRUCTOR_ARGS, cfg, collectionMetadata, cacheAccessStrategy, factory );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:PersisterFactoryImpl.java


注:本文中的org.hibernate.mapping.Collection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。