|
Lines 14-19
Link Here
|
| 14 |
* The class was amended to allow it to instantiate ValueHolders after release method has been called |
14 |
* The class was amended to allow it to instantiate ValueHolders after release method has been called |
| 15 |
* (internalExecuteQuery method no longer throws exception if the uow is dead). |
15 |
* (internalExecuteQuery method no longer throws exception if the uow is dead). |
| 16 |
* Note that release method clears change sets but keeps the cache. |
16 |
* Note that release method clears change sets but keeps the cache. |
|
|
17 |
* 02/10/2009-1.1 Michael O'Brien |
| 18 |
* - 259993: Defer a clear() call to release() if uow lifecycle is 1,2 or 4 (*Pending). |
| 17 |
******************************************************************************/ |
19 |
******************************************************************************/ |
| 18 |
package org.eclipse.persistence.internal.sessions; |
20 |
package org.eclipse.persistence.internal.sessions; |
| 19 |
|
21 |
|
|
Lines 33-38
Link Here
|
| 33 |
import org.eclipse.persistence.internal.sequencing.Sequencing; |
35 |
import org.eclipse.persistence.internal.sequencing.Sequencing; |
| 34 |
import org.eclipse.persistence.sessions.coordination.MergeChangeSetCommand; |
36 |
import org.eclipse.persistence.sessions.coordination.MergeChangeSetCommand; |
| 35 |
import org.eclipse.persistence.sessions.factories.ReferenceMode; |
37 |
import org.eclipse.persistence.sessions.factories.ReferenceMode; |
|
|
38 |
import org.eclipse.persistence.logging.AbstractSessionLog; |
| 36 |
import org.eclipse.persistence.logging.SessionLog; |
39 |
import org.eclipse.persistence.logging.SessionLog; |
| 37 |
import org.eclipse.persistence.mappings.DatabaseMapping; |
40 |
import org.eclipse.persistence.mappings.DatabaseMapping; |
| 38 |
import org.eclipse.persistence.internal.localization.LoggingLocalization; |
41 |
import org.eclipse.persistence.internal.localization.LoggingLocalization; |
|
Lines 3195-3200
Link Here
|
| 3195 |
* for synchronized units of work, merge changes into parent |
3198 |
* for synchronized units of work, merge changes into parent |
| 3196 |
*/ |
3199 |
*/ |
| 3197 |
public void mergeClonesAfterCompletion() { |
3200 |
public void mergeClonesAfterCompletion() { |
|
|
3201 |
// Before we merge |
| 3202 |
// Check that the current thread is the active thread on all lock managers by checking the cached lockThread on the mergeManager. |
| 3203 |
// If we find that these 2 threads are different - then all threads in the acquired locks list are different. |
| 3204 |
// Switch the activeThread on the mutex to this current thread for each lock |
| 3205 |
Thread currentThread = Thread.currentThread(); |
| 3206 |
if(null != this.getMergeManager()) { // mergeManager may be null in a com.ibm.tx.jta.RegisteredSyncs.coreDistributeAfter() afterCompletion() callback |
| 3207 |
Thread lockThread = this.getMergeManager().getLockThread(); |
| 3208 |
if(currentThread != lockThread) { |
| 3209 |
ArrayList<CacheKey> locks = this.getMergeManager().getAcquiredLocks(); |
| 3210 |
if(null != locks) { |
| 3211 |
Iterator<CacheKey> locksIterator = locks.iterator(); |
| 3212 |
AbstractSessionLog.getLog().log(SessionLog.FINER, "active_thread_is_different_from_current_thread", |
| 3213 |
lockThread, this.getMergeManager(), currentThread); |
| 3214 |
while(locksIterator.hasNext()) { |
| 3215 |
ConcurrencyManager lockMutex = locksIterator.next().getMutex(); |
| 3216 |
if(null != lockMutex) { |
| 3217 |
Thread activeThread = lockMutex.getActiveThread(); |
| 3218 |
// check for different acquire and release threads |
| 3219 |
if(currentThread != activeThread) { |
| 3220 |
// Switch activeThread to currentThread - we will release the lock later |
| 3221 |
lockMutex.setActiveThread(currentThread); |
| 3222 |
} |
| 3223 |
} |
| 3224 |
} |
| 3225 |
} |
| 3226 |
} |
| 3227 |
} |
| 3228 |
|
| 3198 |
mergeChangesIntoParent(); |
3229 |
mergeChangesIntoParent(); |
| 3199 |
// CR#... call event and log. |
3230 |
// CR#... call event and log. |
| 3200 |
getEventManager().postCommitUnitOfWork(); |
3231 |
getEventManager().postCommitUnitOfWork(); |
|
Lines 5289-5305
Link Here
|
| 5289 |
this.optimisticReadLockObjects = null; |
5320 |
this.optimisticReadLockObjects = null; |
| 5290 |
this.batchReadObjects = null; |
5321 |
this.batchReadObjects = null; |
| 5291 |
if(shouldClearCache) { |
5322 |
if(shouldClearCache) { |
| 5292 |
this.getIdentityMapAccessor().initializeIdentityMaps(); |
5323 |
clearIdentityMapCache(); |
| 5293 |
if (this.getParent() instanceof IsolatedClientSession) { |
|
|
| 5294 |
this.getParent().getIdentityMapAccessor().initializeIdentityMaps(); |
| 5295 |
} |
| 5296 |
} |
5324 |
} |
| 5297 |
} |
5325 |
} |
|
|
5326 |
|
| 5327 |
/** |
| 5328 |
* INTERNAL: |
| 5329 |
* Clear the identityMaps |
| 5330 |
*/ |
| 5331 |
private void clearIdentityMapCache() { |
| 5332 |
this.getIdentityMapAccessor().initializeIdentityMaps(); |
| 5333 |
if (this.getParent() instanceof IsolatedClientSession) { |
| 5334 |
this.getParent().getIdentityMapAccessor().initializeIdentityMaps(); |
| 5335 |
} |
| 5336 |
} |
| 5298 |
|
5337 |
|
| 5299 |
/** |
5338 |
/** |
| 5300 |
* INTERNAL: |
5339 |
* INTERNAL: |
| 5301 |
* Call this method if the uow will no longer used for committing transactions: |
5340 |
* Call this method if the uow will no longer be used for committing transactions: |
| 5302 |
* all the changes sets will be dereferenced, and (optionally) the cache cleared. |
5341 |
* all the change sets will be dereferenced, and (optionally) the cache cleared. |
| 5303 |
* If the uow is not released, but rather kept around for ValueHolders, then identity maps shouldn't be cleared: |
5342 |
* If the uow is not released, but rather kept around for ValueHolders, then identity maps shouldn't be cleared: |
| 5304 |
* the parameter value should be 'false'. The lifecycle set to Birth so that uow ValueHolder still could be used. |
5343 |
* the parameter value should be 'false'. The lifecycle set to Birth so that uow ValueHolder still could be used. |
| 5305 |
* Alternatively, if called from release method then everything should go and therefore parameter value should be 'true'. |
5344 |
* Alternatively, if called from release method then everything should go and therefore parameter value should be 'true'. |
|
Lines 5307-5314
Link Here
|
| 5307 |
* The reason for calling this method from release is to free maximum memory right away: |
5346 |
* The reason for calling this method from release is to free maximum memory right away: |
| 5308 |
* the uow might still be referenced by objects using UOWValueHolders (though they shouldn't be around |
5347 |
* the uow might still be referenced by objects using UOWValueHolders (though they shouldn't be around |
| 5309 |
* they still might). |
5348 |
* they still might). |
|
|
5349 |
* We defer a clear() call to release() if the uow lifecycle is 1,2 or 4 (*Pending). |
| 5310 |
*/ |
5350 |
*/ |
| 5311 |
public void clearForClose(boolean shouldClearCache) { |
5351 |
public void clearForClose(boolean shouldClearCache) { |
|
|
5352 |
// WebSphere 7.0 during a JPAEMPool.putEntityManager() may attempt to clear an entityManager |
| 5353 |
// that is in the middle of a commit. |
| 5354 |
// We only clear the entityManager if we are in the states |
| 5355 |
// (Birth == 0, WriteChangesFailed==3, Death==5 or AfterExternalTransactionRolledBack==6). |
| 5356 |
// If we are in one of the following *Pending states we defer the clear() to the release() call later |
| 5357 |
if(this.getLifecycle() == this.CommitPending |
| 5358 |
|| this.getLifecycle() == this.CommitTransactionPending |
| 5359 |
|| this.getLifecycle() == this.MergePending) { |
| 5360 |
// perform a partial clear() by clearing the identityMaps but leaving all other fields set |
| 5361 |
// later in release a clear(false) will clear everything else except the identityMaps |
| 5362 |
if(shouldClearCache) { |
| 5363 |
clearIdentityMapCache(); |
| 5364 |
} |
| 5365 |
// We must exit before we perform a full clear |
| 5366 |
return; |
| 5367 |
} |
| 5368 |
|
| 5312 |
clear(shouldClearCache); |
5369 |
clear(shouldClearCache); |
| 5313 |
if(isActive()) { |
5370 |
if(isActive()) { |
| 5314 |
//Reset lifecycle |
5371 |
//Reset lifecycle |