AnsweredAssumed Answered

Multiple versions point to same url

Question asked by paul.price on Feb 14, 2013
Latest reply on Mar 12, 2013 by paul.price
I found the following SQL somewhere on this site several months ago. It works great for docs that have a single version. However, if there are multiple revisions of a doc, all versions of the doc point to the same content_url. Anyone want to take a shot at improving the SQL so that it will also work with versioned docs?

SELECT  n.uuid ,
FROM    alf_qname AS q
        INNER JOIN alf_namespace AS ns ON q.ns_id =
        INNER JOIN alf_node AS n
        INNER JOIN alf_node_properties AS p ON = p.node_id ON = p.qname_id
        INNER JOIN alf_content_data AS d ON p.long_value =
        INNER JOIN alf_content_url AS u ON d.content_url_id =
WHERE   ( q.local_name = 'content' )
        AND ( ns.uri = '' )
ORDER BY u.content_url


In looking at my database, it appears that the ALF_CONTENT_DATA table maps all the versions of a doc to the same CONTENT_URL_ID.

It should be noted that this data was initially uploaded into Alfresco using the CMIS interface in Alfresco 3.4.1. I have done an "in place" upgrade to So it is entirely possible that the problem originated in the older version of Alfresco.

Adding some additional tables to the SQL might make the problem a little easier to see.

SELECT  node.uuid AS [NodeUuid(Search)] ,
        prop.node_id AS PropNodeId , AS CDid ,
        contentdata.content_url_id ,
        node.version AS NodeVer ,
        url.content_url AS [ContentUrl(Returned)] ,
FROM    alf_qname AS qname
        INNER JOIN alf_namespace AS namespace ON qname.ns_id =
        INNER JOIN alf_node AS node
        INNER JOIN alf_node_properties AS prop ON = prop.node_id ON = prop.qname_id
        INNER JOIN alf_content_data AS contentdata ON prop.long_value =
        INNER JOIN alf_content_url AS url ON contentdata.content_url_id =
WHERE   ( qname.local_name = 'content' )
        AND ( namespace.uri = '' )
ORDER BY url.content_url

Also, my intention for this nasty query is to build a map from alf_node.uuid to the alf_content_url.content_url. I will use this map to migrate old docs into a new system using the bulk loader. I need to add new meta data to the migrated docs that is currently stored in a separate database that uses the alf_nade.uuid as its key.

SELECT AS version_id , AS series_id ,
        propFileName.string_value AS file_name ,
        propVersion.string_value AS version ,
        url.content_url ,
        node.uuid AS version_uuid ,
        nodeSeries.uuid AS series_uuid
FROM    alf_node AS node
        INNER JOIN alf_node_properties AS propSeries ON = propSeries.node_id
        INNER JOIN alf_node_properties AS propVersion ON = propVersion.node_id
        INNER JOIN alf_node_properties AS propFileName ON = propFileName.node_id
        INNER JOIN alf_node_properties AS propContent ON = propContent.node_id
        INNER JOIN alf_qname AS qnameFrozen ON = propSeries.qname_id
        INNER JOIN alf_qname AS qnameVerLabel ON = propVersion.qname_id
        INNER JOIN alf_qname AS qnameLocalName ON = propFileName.qname_id
        INNER JOIN alf_qname AS qnameContent ON = propContent.qname_id
        INNER JOIN alf_namespace AS namespaceVersion ON qnameVerLabel.ns_id =
        INNER JOIN alf_namespace AS namespaceContent ON qnameContent.ns_id =
        INNER JOIN alf_content_data AS ContentData ON propContent.long_value =
        INNER JOIN alf_content_url AS url ON ContentData.content_url_id =
        INNER JOIN alf_node AS nodeSeries ON propSeries.long_value =
WHERE   ( qnameFrozen.local_name = 'frozenNodeDbId' )
        AND ( qnameVerLabel.local_name = 'versionLabel' )
        AND ( qnameLocalName.local_name = 'name' )
        AND ( qnameContent.local_name = 'content' )
        AND ( namespaceContent.uri = '' )
        AND ( namespaceVersion.uri = '' )
        AND ( qnameLocalName.ns_id = )