FileDocCategorySizeDatePackage
CustomCollectionType.javaAPI DocHibernate 3.2.53376Tue May 08 22:52:56 BST 2007org.hibernate.type

CustomCollectionType

public class CustomCollectionType extends CollectionType
A custom type for mapping user-written classes that implement PersistentCollection
see
org.hibernate.collection.PersistentCollection
see
org.hibernate.usertype.UserCollectionType
author
Gavin King

Fields Summary
private final org.hibernate.usertype.UserCollectionType
userType
private final boolean
customLogging
Constructors Summary
public CustomCollectionType(Class userTypeClass, String role, String foreignKeyPropertyName, boolean isEmbeddedInXML)

		super(role, foreignKeyPropertyName, isEmbeddedInXML);

		if ( !UserCollectionType.class.isAssignableFrom( userTypeClass ) ) {
			throw new MappingException( "Custom type does not implement UserCollectionType: " + userTypeClass.getName() );
		}

		try {
			userType = ( UserCollectionType ) userTypeClass.newInstance();
		}
		catch ( InstantiationException ie ) {
			throw new MappingException( "Cannot instantiate custom type: " + userTypeClass.getName() );
		}
		catch ( IllegalAccessException iae ) {
			throw new MappingException( "IllegalAccessException trying to instantiate custom type: " + userTypeClass.getName() );
		}

		customLogging = LoggableUserType.class.isAssignableFrom( userTypeClass );
	
Methods Summary
public booleancontains(java.lang.Object collection, java.lang.Object entity, org.hibernate.engine.SessionImplementor session)

		return userType.contains(collection, entity);
	
public java.util.IteratorgetElementsIterator(java.lang.Object collection)

		return userType.getElementsIterator(collection);
	
public java.lang.ClassgetReturnedClass()

		return userType.instantiate( -1 ).getClass();
	
public org.hibernate.usertype.UserCollectionTypegetUserType()

		return userType;
	
public java.lang.ObjectindexOf(java.lang.Object collection, java.lang.Object entity)

		return userType.indexOf(collection, entity);
	
public org.hibernate.collection.PersistentCollectioninstantiate(org.hibernate.engine.SessionImplementor session, org.hibernate.persister.collection.CollectionPersister persister, java.io.Serializable key)

		return userType.instantiate(session, persister);
	
public java.lang.Objectinstantiate(int anticipatedType)

		return userType.instantiate( anticipatedType );
	
protected java.lang.StringrenderLoggableString(java.lang.Object value, org.hibernate.engine.SessionFactoryImplementor factory)

		if ( customLogging ) {
			return ( ( LoggableUserType ) userType ).toLoggableString( value, factory );
		}
		else {
			return super.renderLoggableString( value, factory );
		}
	
public java.lang.ObjectreplaceElements(java.lang.Object original, java.lang.Object target, java.lang.Object owner, java.util.Map copyCache, org.hibernate.engine.SessionImplementor session)

		CollectionPersister cp = session.getFactory().getCollectionPersister( getRole() );
		return userType.replaceElements(original, target, cp, owner, copyCache, session);
	
public org.hibernate.collection.PersistentCollectionwrap(org.hibernate.engine.SessionImplementor session, java.lang.Object collection)

		return userType.wrap(session, collection);