Revision 348d552a
Added by Cherian Mathew about 9 years ago
eu.etaxonomy.taxeditor.cdmlib/src/main/java/org/hibernate/collection/internal/AbstractPersistentCollection.java | ||
---|---|---|
61 | 61 |
|
62 | 62 |
import eu.etaxonomy.cdm.api.application.CdmApplicationRemoteConfiguration; |
63 | 63 |
import eu.etaxonomy.taxeditor.remoting.CdmEagerLoadingException; |
64 |
import eu.etaxonomy.taxeditor.remoting.cache.ProxyUtils; |
|
64 | 65 |
import eu.etaxonomy.taxeditor.service.ICachedCommonService; |
65 |
import eu.etaxonomy.taxeditor.service.CachedCommonServiceImpl.CollectionField; |
|
66 | 66 |
|
67 | 67 |
/** |
68 | 68 |
* Base class implementing {@link org.hibernate.collection.spi.PersistentCollection} |
... | ... | |
592 | 592 |
* @throws LazyInitializationException if we cannot initialize |
593 | 593 |
*/ |
594 | 594 |
protected final void initialize(final boolean writing) { |
595 |
// In remoting we are sure that session is null |
|
596 |
// both when using property paths and switching off conversations |
|
597 |
if(session == null && remoting) { |
|
598 |
remoteInitialize(); |
|
599 |
} |
|
600 |
|
|
601 |
if ( initialized ) { |
|
602 |
return; |
|
603 |
} |
|
604 |
|
|
605 |
|
|
606 |
withTemporarySessionIfNeeded( |
|
607 |
new LazyInitializationWork<Object>() { |
|
608 |
@Override |
|
609 |
public Object doWork() { |
|
610 |
session.initializeCollection( AbstractPersistentCollection.this, writing ); |
|
611 |
return null; |
|
612 |
} |
|
613 |
} |
|
614 |
); |
|
595 |
if ( initialized ) { |
|
596 |
return; |
|
597 |
} |
|
598 |
|
|
599 |
// In remoting we are sure that session is null |
|
600 |
// both when using property paths and switching off conversations |
|
601 |
if(session == null && remoting) { |
|
602 |
remoteInitialize(); |
|
603 |
} else { |
|
604 |
withTemporarySessionIfNeeded( |
|
605 |
new LazyInitializationWork<Object>() { |
|
606 |
@Override |
|
607 |
public Object doWork() { |
|
608 |
session.initializeCollection( AbstractPersistentCollection.this, writing ); |
|
609 |
return null; |
|
610 |
} |
|
611 |
} |
|
612 |
); |
|
613 |
} |
|
615 | 614 |
} |
616 | 615 |
|
617 | 616 |
private void throwLazyInitializationExceptionIfNotConnected() { |
... | ... | |
1307 | 1306 |
throw new HibernateException("commonService not initialized (null)"); |
1308 | 1307 |
} |
1309 | 1308 |
|
1310 |
PersistentCollection col = cachedCommonService.initializeCollection(this);
|
|
1309 |
Object obj = ProxyUtils.deproxy(cachedCommonService.initializeCollection(this));
|
|
1311 | 1310 |
afterInitialize(); |
1312 | 1311 |
|
1313 | 1312 |
Class<?> clazz = getClass(); |
1314 | 1313 |
if (clazz != null) { |
1315 |
CollectionField cf = cachedCommonService.getCollectionField(col); |
|
1316 |
cachedCommonService.updatePersistentCollection(cf); |
|
1317 |
Field field = clazz.getDeclaredField(cf.getType().toString()); |
|
1314 |
//CollectionField cf = cachedCommonService.getCollectionField(col); |
|
1315 |
//cachedCommonService.updatePersistentCollection(cf); |
|
1316 |
Object collectionType = ProxyUtils.getCollectionType(obj); |
|
1317 |
Field field = clazz.getDeclaredField(collectionType.toString()); |
|
1318 | 1318 |
field.setAccessible(true); |
1319 |
field.set(this, cf.getCollection()); |
|
1319 |
field.set(this, obj); |
|
1320 |
ProxyUtils.setRoleValueInOwner(owner, role, obj); |
|
1321 |
|
|
1320 | 1322 |
} |
1321 | 1323 |
} catch (Exception ex) { |
1322 | 1324 |
throw new CdmEagerLoadingException(ex); |
Also available in: Unified diff
AbstractPersistentCollection : fixed loading of collection
MockCdmEntitySessionManager, MockCdmEntitySession, ICdmEntitySessionManager, ICdmEntitySession, CdmEntitySessionManager,
CdmEntitySession : added new load method with choice to update client object graph
TermServiceRequestExecutor : using cacher instead of cache
ICachedCommonService, CachedCommonServiceImpl, ProxyUtils : moved utility methods to utility class
CdmServiceRequestExecutor : updating client object graph when calling merge
EntityCacherDebugResult : corrections for output string
CdmTransientEntityCacher : corrected cache configuration, added load methods with update choice, added service cacher check before put
CacheLoader : checking in recursive call if collection and maps are already visited
CdmRemotingException : added constructor with exception as argument
CdmServiceCacher : corrected cache configuration and loading of entities from default cache