Hibernate version:
3.0b4
In hibernate 3.0b3 I implemented my custom UserCollection by adding a new class (HibernateHQLPersistentSet) extending PersistentSet and implementing my own collection business interface and adding a new class implementing UserCollectionType (HibernateHQLSetType) defined as follow:
Code:
public class HibernateHQLSetType implements UserCollectionType {
public PersistentCollection instantiate(SessionImplementor arg0,
CollectionPersister arg1) throws HibernateException {
return new HibernateHQLPersistentSet(arg0);
}
public PersistentCollection wrap(SessionImplementor arg0, Object arg1) {
return new HibernateHQLPersistentSet(arg0, (Set) arg1);
}
}
When I upgraded to hibernate 3.0b4 I found that I should implement the following methods of the UserCollectionType interface!
Code:
/**
* Optional operation. Does the collection contain the entity instance?
*/
public boolean contains(Object collection, Object entity);
/**
* Optional operation. Return the index of the entity in the collection.
*/
public Object indexOf(Object collection, Object entity);
What should I do if I don't want to implement the optional methods? Should I throw an UnsupportedOperationException?
Code:
/**
* Return an iterator over the elements of this collection - the passed collection
* instance may or may not be a wrapper
*/
public Iterator getElementsIterator(Object collection);
/**
* Replace the elements of a collection with the elements of another collection
*/
public void replaceElements(
Object original,
Object target,
CollectionPersister persister,
Object owner,
Map copyCache,
SessionImplementor session)
throws HibernateException;
/**
* Instantiate an empty instance of the "underlying" collection (not a wrapper)
*/
public Object instantiate();
Should I simply change my own HibernateHQLSetType that was only implementing UserCollectionType by extending UserCollectionType or better SetType?