Merged BRANCHES/V3.2 to HEAD:

18564: Fixed ETHREEOH-4031: ParentAssocsCache gets out of date when parent NodeRefs are modified
   18569: Fix ETHREEOH-3632: UI - View versioned properties fails when node associations are present
   18579: Fix failing unit test after CHK-11190
   18580: Fixed parentAssocsCache invalidation for parent NodeRef modification
   18597: Fixed ETHREEOH-3996


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19214 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2010-03-11 11:03:29 +00:00
parent 84b6373ddb
commit 426d419e53
3 changed files with 56 additions and 52 deletions

View File

@@ -1165,8 +1165,7 @@ public class HibernateNodeDaoServiceImpl
// Update the node
updateNode(nodeId, storeRef, null, null);
NodeRef nodeRef = node.getNodeRef();
this.parentAssocsCache.remove(nodeId);
return new Pair<Long, NodeRef>(node.getId(), nodeRef);
}
@@ -1297,6 +1296,9 @@ public class HibernateNodeDaoServiceImpl
DirtySessionMethodInterceptor.flushSession(getSession(), true);
// The cache entry will be overwritten so we don't need to do it here
}
// ETHREEOH-4031: ParentAssocsCache gets out of date when parent NodeRefs are modified
parentAssocsCache.remove(nodeId);
removeParentAssocCacheEntriesForParent(nodeId);
// Change the store
node.setStore(storeAfter);
@@ -1784,6 +1786,48 @@ public class HibernateNodeDaoServiceImpl
getHibernateTemplate().delete(node);
}
}
/**
* Ensures that parent association entries are removed for all children of a given node
*/
private void removeParentAssocCacheEntriesForParent(final Long parentNodeId)
{
HibernateCallback getChildNodeIdsCallback = new HibernateCallback()
{
public Object doInHibernate(Session session)
{
Query query = session
.getNamedQuery(HibernateNodeDaoServiceImpl.QUERY_GET_CHILD_NODE_IDS)
.setLong("parentId", parentNodeId);
DirtySessionMethodInterceptor.setQueryFlushMode(session, query);
return query.scroll(ScrollMode.FORWARD_ONLY);
}
};
ScrollableResults results = null;
try
{
results = (ScrollableResults) getHibernateTemplate().execute(getChildNodeIdsCallback);
while (results.next())
{
Long childNodeId = results.getLong(0);
parentAssocsCache.remove(childNodeId);
if (isDebugParentAssocCacheEnabled)
{
loggerParentAssocsCache.debug(
"Parent associations cache - Removing entry: \n" +
" Node: " + childNodeId);
}
}
}
finally
{
if(results != null)
{
results.close();
}
}
}
private static final String QUERY_DELETE_PARENT_ASSOCS = "node.DeleteParentAssocs";
private static final String QUERY_DELETE_CHILD_ASSOCS = "node.DeleteChildAssocs";
@@ -1808,39 +1852,9 @@ public class HibernateNodeDaoServiceImpl
{
logger.debug("Deleting child assocs of node " + nodeId);
}
HibernateCallback getChildNodeIdsCallback = new HibernateCallback()
{
public Object doInHibernate(Session session)
{
Query query = session
.getNamedQuery(HibernateNodeDaoServiceImpl.QUERY_GET_CHILD_NODE_IDS)
.setLong("parentId", nodeId);
DirtySessionMethodInterceptor.setQueryFlushMode(session, query);
return query.scroll(ScrollMode.FORWARD_ONLY);
}
};
ScrollableResults childNodeIds = null;
try
{
childNodeIds = (ScrollableResults) getHibernateTemplate().execute(getChildNodeIdsCallback);
// Make sure that the cache is updated
removeParentAssocCacheEntriesForParent(nodeId);
while (childNodeIds.next())
{
Long childNodeId = childNodeIds.getLong(0);
parentAssocsCache.remove(childNodeId);
if (isDebugParentAssocCacheEnabled)
{
loggerParentAssocsCache.debug("\n" + "Parent associations cache - Removing entry: \n" + " Node: " + childNodeId);
}
}
}
finally
{
if(childNodeIds != null)
{
childNodeIds.close();
}
}
HibernateCallback deleteParentAssocsCallback = new HibernateCallback()
{
public Object doInHibernate(Session session)