/** * Called after reading all rows from the JDBC result set */ public boolean endRead() { //override on some subclasses return afterInitialize(); }
public void beginRead() { super.beginRead(); tempList = new ArrayList(); }
/** * Called by any writer method of the collection interface */ protected final void write() { initialize(true); dirty(); } /**
public boolean afterInitialize() { setInitialized(); //do this bit after setting initialized to true or it will recurse if (additions!=null) { delayedAddAll(additions); additions=null; return false; } else { return true; } }
/** * Is this collection in a state that would allow us to * "queue" puts? This is a special case, because of orphan * delete. */ protected boolean isPutQueueEnabled() { return !initialized && isConnectedToSession() && isInverseOneToManyOrNoOrphanDelete(); } /**
/** * @see java.util.Collection#removeAll(Collection) */ public boolean removeAll(Collection c) { write(); return list.removeAll(c); }
private void throwLazyInitializationExceptionIfNotConnected() { if ( !isConnectedToSession() ) { throwLazyInitializationException("no session or session was closed"); } if ( !session.isConnected() ) { throwLazyInitializationException("session is disconnected"); } }
/** * Is this collection in a state that would allow us to * "queue" operations? */ protected boolean isOperationQueueEnabled() { return !initialized && isConnectedToSession() && isInverseCollection(); } /**
/** * Is this collection in a state that would allow us to * "queue" clear? This is a special case, because of orphan * delete. */ protected boolean isClearQueueEnabled() { return !initialized && isConnectedToSession() && isInverseCollectionNoOrphanDelete(); }
public boolean afterInitialize() { setInitialized(); //do this bit after setting initialized to true or it will recurse if (operationQueue!=null) { performQueuedOperations(); operationQueue=null; cachedSize = -1; return false; } else { return true; } }
/** * Associate the collection with the given session. * @return false if the collection was already associated with the session * @throws HibernateException if the collection was already associated * with another open session */ public final boolean setCurrentSession(SessionImplementor session) throws HibernateException { if (session==this.session) { return false; } else { if ( isConnectedToSession() ) { throw new HibernateException("Illegal attempt to associate a collection with two open sessions"); } else { this.session = session; return true; } } }
/** * Called by any read-only method of the collection interface */ protected final void read() { initialize(false); } /**
/** * After flushing, clear any "queued" additions, since the * database state is now synchronized with the memory state. */ public void postAction() { operationQueue=null; cachedSize = -1; clearDirty(); }
/** * @see java.util.Collection#add(Object) */ public boolean add(Object o) { write(); return list.add(o); }
/** * Initialize the collection, if possible, wrapping any exceptions * in a runtime exception * @param writing currently obsolete * @throws LazyInitializationException if we cannot initialize */ protected final void initialize(boolean writing) { if (!initialized) { if (initializing) { throw new LazyInitializationException("illegal access to loading collection"); } if ( isConnectedToSession() ) { if ( session.isConnected() ) { session.initializeCollection(this, writing); } else { throwLazyInitializationException("session is disconnected"); } } else { throwLazyInitializationException("no session or session was closed"); } } }
/** * Is this collection in a state that would allow us to * "queue" additions? */ private boolean isQueueAdditionEnabled() { return !initialized && isConnectedToSession() && session.getPersistenceContext().isInverseCollection(this); } /**
/** * Called by any read-only method of the collection interface */ protected final void read() { initialize(false); } /**
/** * @see java.util.Collection#clear() */ public void clear() { write(); list.clear(); }
public void beginRead() { super.beginRead(); tempList = new ArrayList(); } public boolean endRead() {
if ( isConnectedToSession() ) { CollectionEntry ce = session.getPersistenceContext().getCollectionEntry(this); if (ce==null) {