/** * After reading all existing elements from the database, * add the queued elements to the underlying collection. */ protected final void performQueuedOperations() { for ( DelayedOperation operation : operationQueue ) { operation.operate(); } clearOperationQueue(); }
/** * Called by any writer method of the collection interface */ protected final void write() { initialize( true ); dirty(); }
/** * Is this collection in a state that would allow us to * "queue" clear? This is a special case, because of orphan * delete. */ @SuppressWarnings({"JavaDoc"}) protected boolean isClearQueueEnabled() { return !initialized && isConnectedToSession() && isInverseCollectionNoOrphanDelete(); }
@Override @SuppressWarnings("unchecked") public boolean add(Object object) { if ( !isOperationQueueEnabled() ) { write(); return list.add( object ); } else { queueOperation( new SimpleAdd( object ) ); return true; } }
@Override public Collection getOrphans(Serializable snapshot, String entityName) throws HibernateException { final List sn = (List) snapshot; return getOrphans( sn, bag, entityName, getSession() ); }
@Override public Collection getOrphans(Serializable snapshot, String entityName) throws HibernateException { final List sn = (List) snapshot; return getOrphans( sn, list, entityName, getSession() ); }
@Override public PersistentCollection instantiate(SharedSessionContractImplementor session, CollectionPersister persister, Serializable key) { PersistentSortedMap map = new PersistentSortedMap(session); map.setComparator(comparator); return map; }
@Override @SuppressWarnings("unchecked") public SortedMap tailMap(Object fromKey) { read(); final SortedMap tailMap = ( (SortedMap) map ).tailMap( fromKey ); return new SortedSubMap( tailMap ); }
@Override @SuppressWarnings("unchecked") public ListIterator listIterator(int index) { read(); return new ListIteratorProxy( list.listIterator( index ) ); }
@Override @SuppressWarnings("unchecked") public ListIterator listIterator(int i) { read(); return new ListIteratorProxy( bag.listIterator( i ) ); }
@Override @SuppressWarnings("unchecked") public SortedSet subSet(Object fromElement, Object toElement) { read(); final SortedSet subSet = ( (SortedSet) set ).subSet( fromElement, toElement ); return new SubSetProxy( subSet ); }
@Override public void postAction() { clearOperationQueue(); cachedSize = -1; clearDirty(); }
@Override public PersistentCollection wrap(SharedSessionContractImplementor session, Object collection) { return new PersistentBag( session, (Collection) collection ); }
@Override public PersistentCollection wrap(SharedSessionContractImplementor session, Object collection) { return new PersistentMap( session, (java.util.Map) collection ); }
/** * Called by any read-only method of the collection interface */ protected final void read() { initialize( false ); }
/** * Constructs a PersistentCollection instance for holding an array. * * @param session The session * @param array The array (the persistent "collection"). */ public PersistentArrayHolder(SharedSessionContractImplementor session, Object array) { super( session ); this.array = array; setInitialized(); }
@Override public PersistentCollection instantiate(SharedSessionContractImplementor session, CollectionPersister persister, Serializable key) throws HibernateException { return new PersistentArrayHolder(session, persister); }
@Override public boolean endRead() { //override on some subclasses return afterInitialize(); }
@Override @SuppressWarnings("unchecked") public Iterator entries(CollectionPersister persister) { return elements(); }