/** * INTERNAL: * Cache the locking policy isReferenceClassLocked check. */ protected boolean isReferenceClassLocked() { if (isReferenceClassLocked == null) { isReferenceClassLocked = Boolean.valueOf(isLockQuery() && lockingClause.isReferenceClassLocked()); } return isReferenceClassLocked.booleanValue(); }
/** * INTERNAL: * Cache the locking policy isReferenceClassLocked check. */ protected boolean isReferenceClassLocked() { if (isReferenceClassLocked == null) { isReferenceClassLocked = Boolean.valueOf(isLockQuery() && lockingClause.isReferenceClassLocked()); } return isReferenceClassLocked.booleanValue(); }
/** * INTERNAL: * Cache the locking policy isReferenceClassLocked check. */ protected boolean isReferenceClassLocked() { if (isReferenceClassLocked == null) { isReferenceClassLocked = Boolean.valueOf(isLockQuery() && lockingClause.isReferenceClassLocked()); } return isReferenceClassLocked.booleanValue(); }
/** * ADVANCED: * Answers if this query will issue any pessimistic locks. * <p> * If the lock mode is not known (DEFAULT_LOCK_MODE / descriptor specified * fine-grained locking) the lock mode will be determined now, to be either * LOCK, LOCK_NOWAIT, or NO_LOCK. * @see #isLockQuery() */ public boolean isLockQuery(org.eclipse.persistence.sessions.Session session) { checkPrePrepare((AbstractSession)session); return isLockQuery(); }
/** * ADVANCED: * Answers if this query will issue any pessimistic locks. * <p> * If the lock mode is not known (DEFAULT_LOCK_MODE / descriptor specified * fine-grained locking) the lock mode will be determined now, to be either * LOCK, LOCK_NOWAIT, or NO_LOCK. * @see #isLockQuery() */ public boolean isLockQuery(org.eclipse.persistence.sessions.Session session) { checkPrePrepare((AbstractSession)session); return isLockQuery(); }
/** * ADVANCED: * Answers if this query will issue any pessimistic locks. * <p> * If the lock mode is not known (DEFAULT_LOCK_MODE / descriptor specified * fine-grained locking) the lock mode will be determined now, to be either * LOCK, LOCK_NOWAIT, or NO_LOCK. * @see #isLockQuery() */ public boolean isLockQuery(org.eclipse.persistence.sessions.Session session) { checkPrePrepare((AbstractSession)session); return isLockQuery(); }
/** * INTERNAL: Answers if this valueholder is a pessimistic locking one. Such * valueholders are special in that they can be triggered multiple times by * different UnitsOfWork. Each time a lock query will be issued. Hence even * if instantiated it may have to be instantiated again, and once * instantiated all fields can not be reset. * <p> * Since locks will be issued each time this valueholder is triggered, * triggering this directly on the session in auto commit mode will generate * an exception. This only UnitOfWorkValueHolder's wrapping this can trigger * it. Note: This method is not thread-safe. It must be used in a * synchronized manner */ public boolean isPessimisticLockingValueHolder() { // Get the easy checks out of the way first. if ((this.query == null) || !this.query.isObjectLevelReadQuery()) { return false; } ObjectLevelReadQuery query = (ObjectLevelReadQuery) this.query; // Note even if the reference class is not locked, but the valueholder // query // has joined attributes, then this may count as a lock query. // This means it is possible to trigger a valueholder to get an object // which // is not to be pess. locked and get an exception for triggering it on // the // session outside a transaction. return query.isLockQuery(this.session); }
/** * INTERNAL: Answers if this valueholder is a pessimistic locking one. Such * valueholders are special in that they can be triggered multiple times by * different UnitsOfWork. Each time a lock query will be issued. Hence even * if instantiated it may have to be instantiated again, and once * instantiated all fields can not be reset. * <p> * Since locks will be issued each time this valueholder is triggered, * triggering this directly on the session in auto commit mode will generate * an exception. This only UnitOfWorkValueHolder's wrapping this can trigger * it. Note: This method is not thread-safe. It must be used in a * synchronized manner */ public boolean isPessimisticLockingValueHolder() { // Get the easy checks out of the way first. if ((this.query == null) || !this.query.isObjectLevelReadQuery()) { return false; } ObjectLevelReadQuery query = (ObjectLevelReadQuery) this.query; // Note even if the reference class is not locked, but the valueholder // query // has joined attributes, then this may count as a lock query. // This means it is possible to trigger a valueholder to get an object // which // is not to be pess. locked and get an exception for triggering it on // the // session outside a transaction. return query.isLockQuery(this.session); }
/** * INTERNAL: * Answers if we are executing through a UnitOfWork and registering results. * This is only ever false if using the conforming without registering * feature. */ protected boolean isRegisteringResults() { return ((shouldRegisterResultsInUnitOfWork() && this.descriptor.shouldRegisterResultsInUnitOfWork()) || isLockQuery()); }
return query.isLockQuery(getSession());
/** * INTERNAL: * Answers if this valueholder is a pessimistic locking one. Such valueholders * are special in that they can be triggered multiple times by different * UnitsOfWork. Each time a lock query will be issued. Hence even if * instantiated it may have to be instantiated again, and once instantatiated * all fields can not be reset. * Note: This method is not thread-safe. It must be used in a synchronizaed manner */ public boolean isPessimisticLockingValueHolder() { // This abstract method needs to be implemented but is not meaningfull for // this subclass. if (getWrappedServerValueHolder() != null) { return ((getWrappedServerValueHolder() instanceof DatabaseValueHolder) && ((DatabaseValueHolder)getWrappedServerValueHolder()).isPessimisticLockingValueHolder()); } else { // Pessimistic locking may not be supported on remote sessions, but if // it is make every attempt to do the right thing. return ((getQuery() != null) && getQuery().isLockQuery(getSession())); } }
/** * INTERNAL: * Answers if this valueholder is a pessimistic locking one. Such valueholders * are special in that they can be triggered multiple times by different * UnitsOfWork. Each time a lock query will be issued. Hence even if * instantiated it may have to be instantiated again, and once instantatiated * all fields can not be reset. * Note: This method is not thread-safe. It must be used in a synchronizaed manner */ public boolean isPessimisticLockingValueHolder() { // This abstract method needs to be implemented but is not meaningfull for // this subclass. if (getWrappedServerValueHolder() != null) { return ((getWrappedServerValueHolder() instanceof DatabaseValueHolder) && ((DatabaseValueHolder)getWrappedServerValueHolder()).isPessimisticLockingValueHolder()); } else { // Pessimistic locking may not be supported on remote sessions, but if // it is make every attempt to do the right thing. return ((getQuery() != null) && getQuery().isLockQuery(getSession())); } }
/** * INTERNAL: * Answers if this valueholder is a pessimistic locking one. Such valueholders * are special in that they can be triggered multiple times by different * UnitsOfWork. Each time a lock query will be issued. Hence even if * instantiated it may have to be instantiated again, and once instantatiated * all fields can not be reset. * Note: This method is not thread-safe. It must be used in a synchronizaed manner */ public boolean isPessimisticLockingValueHolder() { // This abstract method needs to be implemented but is not meaningfull for // this subclass. if (getWrappedServerValueHolder() != null) { return ((getWrappedServerValueHolder() instanceof DatabaseValueHolder) && ((DatabaseValueHolder)getWrappedServerValueHolder()).isPessimisticLockingValueHolder()); } else { // Pessimistic locking may not be supported on remote sessions, but if // it is make every attempt to do the right thing. return ((getQuery() != null) && getQuery().isLockQuery(getSession())); } }
/** * INTERNAL: * There is a very special case where a query may be a bean-level * pessimistic locking query. * <p> * If that is so, only queries executed inside of a UnitOfWork should * have a locking clause. In the extremely rare case that we execute * a locking query outside of a UnitOfWork, must disable locking so that * we do not get a fetch out of sequence error. */ public DatabaseQuery prepareOutsideUnitOfWork(AbstractSession session) { // Implementation is complicated because: if locking refresh will be // auto set to true preventing cache hit. // Must prepare this query from scratch if outside uow but locking // Must not reprepare this query as a NO_LOCK, but create a clone first // Must not cloneAndUnPrepare unless really have to if (isLockQuery(session) && getLockingClause().isForUpdateOfClause()) { ObjectLevelReadQuery clone = (ObjectLevelReadQuery)clone(); clone.setIsExecutionClone(true); clone.dontAcquireLocks(); clone.setIsPrepared(false); clone.checkPrePrepare(session); return clone; } return this; }
/** * INTERNAL: * There is a very special case where a query may be a bean-level * pessimistic locking query. * <p> * If that is so, only queries executed inside of a UnitOfWork should * have a locking clause. In the extremely rare case that we execute * a locking query outside of a UnitOfWork, must disable locking so that * we do not get a fetch out of sequence error. */ public DatabaseQuery prepareOutsideUnitOfWork(AbstractSession session) { // Implementation is complicated because: if locking refresh will be // auto set to true preventing cache hit. // Must prepare this query from scratch if outside uow but locking // Must not reprepare this query as a NO_LOCK, but create a clone first // Must not cloneAndUnPrepare unless really have to if (isLockQuery(session) && getLockingClause().isForUpdateOfClause()) { ObjectLevelReadQuery clone = (ObjectLevelReadQuery)clone(); clone.setIsExecutionClone(true); clone.dontAcquireLocks(); clone.setIsPrepared(false); clone.checkPrePrepare(session); return clone; } return this; }
/** * INTERNAL: * There is a very special case where a query may be a bean-level * pessimistic locking query. * <p> * If that is so, only queries executed inside of a UnitOfWork should * have a locking clause. In the extremely rare case that we execute * a locking query outside of a UnitOfWork, must disable locking so that * we do not get a fetch out of sequence error. */ public DatabaseQuery prepareOutsideUnitOfWork(AbstractSession session) { // Implementation is complicated because: if locking refresh will be // auto set to true preventing cache hit. // Must prepare this query from scratch if outside uow but locking // Must not reprepare this query as a NO_LOCK, but create a clone first // Must not cloneAndUnPrepare unless really have to if (isLockQuery(session) && getLockingClause().isForUpdateOfClause()) { ObjectLevelReadQuery clone = (ObjectLevelReadQuery)clone(); clone.setIsExecutionClone(true); clone.dontAcquireLocks(); clone.setIsPrepared(false); clone.checkPrePrepare(session); return clone; } return this; }
if ((!unitOfWork.isNestedUnitOfWork()) && (this.descriptor.shouldIsolateObjectsInUnitOfWork() || isLockQuery())) { return null;
if (isLockQuery()) { if ((!unitOfWork.getCommitManager().isActive()) && (!unitOfWork.wasTransactionBegunPrematurely())) { unitOfWork.beginTransaction();
if (readQuery.isLockQuery(this) && !wasTransactionBegunPrematurely()) { beginEarlyTransaction();
if (readQuery.isLockQuery(this) && !wasTransactionBegunPrematurely()) { beginEarlyTransaction();