Hibernate ORM CollectionType - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Hibernate ORM CollectionType class.

This code example shows how to use the following methods:getRole, hasHolder, wrap
	final Object processArrayOrNewCollection(Object collection, CollectionType collectionType) 
	throws HibernateException { 
 
		final SessionImplementor session = getSession(); 
 
		if (collection==null) { 
			//do nothing 
			return null; 
		} 
		else { 
			CollectionPersister persister = session.getFactory().getCollectionPersister( collectionType.getRole() ); 
 
			final PersistenceContext persistenceContext = session.getPersistenceContext(); 
			//TODO: move into collection type, so we can use polymorphism! 
			if ( collectionType.hasHolder() ) { 
 
				if (collection==CollectionType.UNFETCHED_COLLECTION) return null; 
 
				PersistentCollection ah = persistenceContext.getCollectionHolder(collection); 
				if (ah==null) { 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getRole, hasHolder
			return null; 
		} 
 
		if (collection!=null) { 
			final PersistentCollection coll;
			if ( type.hasHolder() ) {
				coll = getSession().getPersistenceContext().getCollectionHolder(collection);
			} 
			else { 
				coll = (PersistentCollection) collection;
			} 
 
			Collections.processReachableCollection( coll, type, owner, getSession() );
		} 
 
		return null; 
 
	} 
 
	FlushVisitor(EventSource session, Object owner) {

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getRole
		try { 
			return ( QueryableCollection ) factory.getCollectionPersister( role );
		} 
		catch ( ClassCastException cce ) {
			throw new QueryException( "collection role is not queryable: " + role );
		} 
		catch ( Exception e ) {
			throw new QueryException( "collection role not found: " + role );
		} 
	} 
 
	public final TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
	        throws HibernateException {
		return NO_VALUES;
	} 
 
	public final String toString() {
		return propertyName + ( excludeEmpty() ? " is not empty" : " is empty" );
	} 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getRole
	 * wrapper 
	 */ 
	protected void reattachCollection(PersistentCollection collection, CollectionType type)
	throws HibernateException {
		if ( collection.wasInitialized() ) {
			CollectionPersister collectionPersister = getSession().getFactory()
			.getCollectionPersister( type.getRole() );
			getSession().getPersistenceContext()
				.addInitializedDetachedCollection( collectionPersister, collection );
		} 
		else { 
			if ( !isCollectionSnapshotValid(collection) ) {
				throw new HibernateException( "could not reassociate uninitialized transient collection" );
			} 
			CollectionPersister collectionPersister = getSession().getFactory()
					.getCollectionPersister( collection.getRole() );
			getSession().getPersistenceContext()
				.addUninitializedDetachedCollection( collectionPersister, collection );
		} 
	} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:hasHolder
		return null; 
	} 
	public void evictCollection(Object value, CollectionType type) { 
 
		final Object pc; 
		if ( type.hasHolder() ) { 
			pc = getSession().getPersistenceContext().removeCollectionHolder(value); 
		} 
		else if ( value instanceof PersistentCollection ) { 
			pc = value; 
		} 
		else { 
			return; //EARLY EXIT! 
		} 
 
		PersistentCollection collection = (PersistentCollection) pc; 
		if ( collection.unsetSession( getSession() ) ) evictCollection(collection); 
	} 
 
	private void evictCollection(PersistentCollection collection) { 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getRole
		if ( ce == null ) { 
			// refer to comment in StatefulPersistenceContext.addCollection() 
			throw new HibernateException( 
					"Found two representations of same collection: " + 
					type.getRole() 
			); 
		} 
 
		// The CollectionEntry.isReached() stuff is just to detect any silly users 
		// who set up circular or shared references between/to collections. 
		if ( ce.isReached() ) { 
			// We've been here before 
			throw new HibernateException( 
					"Found shared references to a collection: " + 
					type.getRole() 
			); 
		} 
		ce.setReached(true); 
 
		SessionFactoryImplementor factory = session.getFactory(); 

4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getRole
		SessionImplementor session = getSession();
		CollectionPersister persister = session.getFactory().getCollectionPersister( type.getRole() );
 
		if ( collection == null ) { 
			//do nothing 
		} 
		else if ( collection instanceof PersistentCollection ) {
			PersistentCollection persistentCollection = ( PersistentCollection ) collection;
			if ( persistentCollection.setCurrentSession( session ) ) {
				if ( isOwnerUnchanged( persistentCollection, persister, extractCollectionKeyFromOwner( persister ) ) ) {
					// a "detached" collection that originally belonged to the same entity 
					if ( persistentCollection.isDirty() ) {
						throw new HibernateException( "reassociated object has dirty collection" );
					} 
					reattachCollection( persistentCollection, type );
				} 
				else { 
					// a "detached" collection that belonged to a different entity 
					throw new HibernateException( "reassociated object has dirty collection reference" );
				} 

4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getRole
		ignoreInitialJoin = false;
 
		Type propertyType = getPropertyType();
		if ( propertyType != null && propertyType.isCollectionType() ) {
			collectionRole = ( ( CollectionType ) propertyType ).getRole();
			collectionName = q.createNameForCollection( collectionRole );
			prepareForIndex( q );
		} 
		else { 
			columns = currentColumns();
			setType(); 
		} 
 
		//important!! 
		continuation = false;
 
	} 
 
	private void prepareForIndex(QueryTranslatorImpl q) throws QueryException {
 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:isArrayType
 
	Object processCollection(Object collection, CollectionType type)
		throws HibernateException {
 
		if (collection!=null) { 
 
			SessionImplementor session = getSession();
 
			final PersistentCollection persistentCollection;
			if ( type.isArrayType() ) {
				 persistentCollection = session.getPersistenceContext().getCollectionHolder(collection);
				// if no array holder we found an unwrappered array (this can't occur, 
				// because we now always call wrap() before getting to here) 
				// return (ah==null) ? true : searchForDirtyCollections(ah, type); 
			} 
			else { 
				// if not wrappered yet, its dirty (this can't occur, because 
				// we now always call wrap() before getting to here) 
				// return ( ! (obj instanceof PersistentCollection) ) ? 
				//true : searchForDirtyCollections( (PersistentCollection) obj, type ); 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getRole
	Object processCollection(Object collection, CollectionType type) throws HibernateException {
 
		if ( collection == CollectionType.UNFETCHED_COLLECTION ) {
			return null; 
		} 
 
		EventSource session = getSession();
		CollectionPersister persister = session.getFactory().getCollectionPersister( type.getRole() );
 
		final Serializable collectionKey = extractCollectionKeyFromOwner( persister );
		if ( collection!=null && (collection instanceof PersistentCollection) ) {
			PersistentCollection wrapper = (PersistentCollection) collection;
			if ( wrapper.setCurrentSession(session) ) {
				//a "detached" collection! 
				if ( !isOwnerUnchanged( wrapper, persister, collectionKey ) ) {
					// if the collection belonged to a different entity, 
					// clean up the existing state of the collection 
					removeCollection( persister, collectionKey, session );
				} 
				reattachCollection(wrapper, type);

4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Hibernate ORM CollectionType Methods: