CustomCollectionTypepublic class CustomCollectionType extends CollectionType A custom type for mapping user-written classes that implement PersistentCollection |
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 boolean | contains(java.lang.Object collection, java.lang.Object entity, org.hibernate.engine.SessionImplementor session)
return userType.contains(collection, entity);
| public java.util.Iterator | getElementsIterator(java.lang.Object collection)
return userType.getElementsIterator(collection);
| public java.lang.Class | getReturnedClass()
return userType.instantiate( -1 ).getClass();
| public org.hibernate.usertype.UserCollectionType | getUserType()
return userType;
| public java.lang.Object | indexOf(java.lang.Object collection, java.lang.Object entity)
return userType.indexOf(collection, entity);
| public org.hibernate.collection.PersistentCollection | instantiate(org.hibernate.engine.SessionImplementor session, org.hibernate.persister.collection.CollectionPersister persister, java.io.Serializable key)
return userType.instantiate(session, persister);
| public java.lang.Object | instantiate(int anticipatedType)
return userType.instantiate( anticipatedType );
| protected java.lang.String | renderLoggableString(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.Object | replaceElements(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.PersistentCollection | wrap(org.hibernate.engine.SessionImplementor session, java.lang.Object collection)
return userType.wrap(session, collection);
|
|