diff --git a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/node-common-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/node-common-SqlMap.xml index 106ce8b23c..c17f2142d3 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/node-common-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/node-common-SqlMap.xml @@ -889,7 +889,7 @@ assoc.assoc_index ASC, assoc.id ASC - + where @@ -926,6 +926,22 @@ childStore.id]]> + + = #{childNode.id} + and 1=1 + order by + ca.child_node_id + ]]> + - + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/node-select-children-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/node-select-children-SqlMap.xml index 60e12e1052..7df7528b81 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/node-select-children-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/node-select-children-SqlMap.xml @@ -8,7 +8,7 @@ diff --git a/source/java/org/alfresco/repo/domain/node/AbstractNodeDAOImpl.java b/source/java/org/alfresco/repo/domain/node/AbstractNodeDAOImpl.java index 26c64630cf..2de1a42bde 100644 --- a/source/java/org/alfresco/repo/domain/node/AbstractNodeDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/node/AbstractNodeDAOImpl.java @@ -519,29 +519,28 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO int count = 0; List childNodeIds = new ArrayList(256); - Long minAssocIdInclusive = Long.MIN_VALUE; - while (minAssocIdInclusive != null) + Long minChildNodeIdInclusive = Long.MIN_VALUE; + while (minChildNodeIdInclusive != null) { childNodeIds.clear(); List childAssocs = selectChildNodeIds( parentNodeId, Boolean.valueOf(primary), - minAssocIdInclusive, + minChildNodeIdInclusive, 256); // Remove the cache entries as we go for (ChildAssocEntity childAssoc : childAssocs) { - Long childAssocId = childAssoc.getId(); - if (childAssocId.compareTo(minAssocIdInclusive) < 0) + Long childNodeId = childAssoc.getChildNode().getId(); + if (childNodeId.compareTo(minChildNodeIdInclusive) < 0) { - throw new RuntimeException("Query results did not increase for assoc ID"); + throw new RuntimeException("Query results did not increase for child node id ID"); } else { - minAssocIdInclusive = new Long(childAssocId.longValue() + 1L); + minChildNodeIdInclusive = new Long(childNodeId.longValue() + 1L); } // Invalidate the node cache - Long childNodeId = childAssoc.getChildNode().getId(); childNodeIds.add(childNodeId); invalidateNodeCaches(childNodeId); count++; diff --git a/source/java/org/alfresco/repo/domain/node/ibatis/NodeDAOImpl.java b/source/java/org/alfresco/repo/domain/node/ibatis/NodeDAOImpl.java index ab7508869e..2439c5b70d 100644 --- a/source/java/org/alfresco/repo/domain/node/ibatis/NodeDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/node/ibatis/NodeDAOImpl.java @@ -877,15 +877,17 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl protected List selectChildNodeIds( Long nodeId, Boolean isPrimary, - Long minAssocIdInclusive, + Long minChildNodeIdInclusive, int maxResults) { ChildAssocEntity assoc = new ChildAssocEntity(); NodeEntity parentNode = new NodeEntity(); parentNode.setId(nodeId); + NodeEntity childNode = new NodeEntity(); + childNode.setId(minChildNodeIdInclusive); assoc.setParentNode(parentNode); assoc.setPrimary(isPrimary); - assoc.setId(minAssocIdInclusive); + assoc.setChildNode(childNode); RowBounds rowBounds = new RowBounds(0, maxResults); return template.selectList(SELECT_CHILD_NODE_IDS, assoc, rowBounds);