mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Removed natural-key declaration from node_assoc table
- This was a nice idea, but mandates that we flush the deleted associations before recreating them (ala version service restore). - For now, we can leave this off git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2875 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -203,27 +203,25 @@
|
|||||||
<id name="id" column="id" type="long" >
|
<id name="id" column="id" type="long" >
|
||||||
<generator class="native" />
|
<generator class="native" />
|
||||||
</id>
|
</id>
|
||||||
<natural-id mutable="true">
|
<!-- forward assoc to source node -->
|
||||||
<!-- forward assoc to source node -->
|
<many-to-one
|
||||||
<many-to-one
|
name="source"
|
||||||
name="source"
|
class="org.alfresco.repo.domain.hibernate.NodeImpl"
|
||||||
class="org.alfresco.repo.domain.hibernate.NodeImpl"
|
lazy="false"
|
||||||
lazy="false"
|
fetch="join"
|
||||||
fetch="join"
|
not-null="true" >
|
||||||
not-null="true" >
|
<column name="source_node_id" />
|
||||||
<column name="source_node_id" />
|
</many-to-one>
|
||||||
</many-to-one>
|
<!-- forward assoc to target node -->
|
||||||
<!-- forward assoc to target node -->
|
<many-to-one
|
||||||
<many-to-one
|
name="target"
|
||||||
name="target"
|
class="org.alfresco.repo.domain.hibernate.NodeImpl"
|
||||||
class="org.alfresco.repo.domain.hibernate.NodeImpl"
|
lazy="false"
|
||||||
lazy="false"
|
fetch="join"
|
||||||
fetch="join"
|
not-null="true" >
|
||||||
not-null="true" >
|
<column name="target_node_id" />
|
||||||
<column name="target_node_id" />
|
</many-to-one>
|
||||||
</many-to-one>
|
<property name="typeQName" column="type_qname" type="QName" length="255" not-null="true" />
|
||||||
<property name="typeQName" column="type_qname" type="QName" length="255" not-null="true" />
|
|
||||||
</natural-id>
|
|
||||||
</class>
|
</class>
|
||||||
|
|
||||||
<query name="store.GetAllStores">
|
<query name="store.GetAllStores">
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.node.db;
|
package org.alfresco.repo.node.db;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.alfresco.repo.domain.ChildAssoc;
|
import org.alfresco.repo.domain.ChildAssoc;
|
||||||
@@ -173,16 +172,6 @@ public interface NodeDaoService
|
|||||||
Node targetNode,
|
Node targetNode,
|
||||||
QName assocTypeQName);
|
QName assocTypeQName);
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Returns the target nodes for the association
|
|
||||||
*/
|
|
||||||
public Collection<Node> getNodeAssocTargets(Node sourceNode, QName assocTypeQName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Returns the source nodes for the association
|
|
||||||
*/
|
|
||||||
public Collection<Node> getNodeAssocSources(Node targetNode, QName assocTypeQName);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param assoc the node association to remove
|
* @param assoc the node association to remove
|
||||||
*/
|
*/
|
||||||
|
@@ -36,6 +36,7 @@ import org.alfresco.repo.domain.hibernate.StoreImpl;
|
|||||||
import org.alfresco.repo.node.db.NodeDaoService;
|
import org.alfresco.repo.node.db.NodeDaoService;
|
||||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||||
import org.alfresco.service.cmr.dictionary.InvalidTypeException;
|
import org.alfresco.service.cmr.dictionary.InvalidTypeException;
|
||||||
|
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
@@ -56,9 +57,6 @@ import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
|||||||
public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements NodeDaoService
|
public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements NodeDaoService
|
||||||
{
|
{
|
||||||
private static final String QUERY_GET_ALL_STORES = "store.GetAllStores";
|
private static final String QUERY_GET_ALL_STORES = "store.GetAllStores";
|
||||||
private static final String QUERY_GET_NODE_ASSOC = "node.GetNodeAssoc";
|
|
||||||
private static final String QUERY_GET_NODE_ASSOC_TARGETS = "node.GetNodeAssocTargets";
|
|
||||||
private static final String QUERY_GET_NODE_ASSOC_SOURCES = "node.GetNodeAssocSources";
|
|
||||||
private static final String QUERY_GET_CONTENT_DATA_STRINGS = "node.GetContentDataStrings";
|
private static final String QUERY_GET_CONTENT_DATA_STRINGS = "node.GetContentDataStrings";
|
||||||
|
|
||||||
/** a uuid identifying this unique instance */
|
/** a uuid identifying this unique instance */
|
||||||
@@ -469,62 +467,27 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
|
|||||||
final Node targetNode,
|
final Node targetNode,
|
||||||
final QName assocTypeQName)
|
final QName assocTypeQName)
|
||||||
{
|
{
|
||||||
HibernateCallback callback = new HibernateCallback()
|
AssociationRef nodeAssocRef = new AssociationRef(
|
||||||
|
sourceNode.getNodeRef(),
|
||||||
|
assocTypeQName,
|
||||||
|
targetNode.getNodeRef());
|
||||||
|
// get all the source's target associations
|
||||||
|
Collection<NodeAssoc> assocs = sourceNode.getTargetNodeAssocs();
|
||||||
|
// hunt down the desired assoc
|
||||||
|
for (NodeAssoc assoc : assocs)
|
||||||
{
|
{
|
||||||
public Object doInHibernate(Session session)
|
// is it a match?
|
||||||
|
if (!assoc.getNodeAssocRef().equals(nodeAssocRef)) // not a match
|
||||||
{
|
{
|
||||||
Query query = session.getNamedQuery(HibernateNodeDaoServiceImpl.QUERY_GET_NODE_ASSOC);
|
continue;
|
||||||
query.setEntity("sourceNode", sourceNode)
|
}
|
||||||
.setEntity("targetNode", targetNode)
|
else
|
||||||
.setString("assocTypeQName", assocTypeQName.toString())
|
{
|
||||||
.setMaxResults(1);
|
return assoc;
|
||||||
return query.uniqueResult();
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
Object queryResult = getHibernateTemplate().execute(callback);
|
|
||||||
if (queryResult == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
NodeAssoc assoc = (NodeAssoc) queryResult;
|
// not found
|
||||||
// done
|
return null;
|
||||||
return assoc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public Collection<Node> getNodeAssocTargets(final Node sourceNode, final QName assocTypeQName)
|
|
||||||
{
|
|
||||||
HibernateCallback callback = new HibernateCallback()
|
|
||||||
{
|
|
||||||
public Object doInHibernate(Session session)
|
|
||||||
{
|
|
||||||
Query query = session.getNamedQuery(HibernateNodeDaoServiceImpl.QUERY_GET_NODE_ASSOC_TARGETS);
|
|
||||||
query.setEntity("sourceNode", sourceNode)
|
|
||||||
.setString("assocTypeQName", assocTypeQName.toString());
|
|
||||||
return query.list();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
List<Node> queryResults = (List) getHibernateTemplate().execute(callback);
|
|
||||||
// done
|
|
||||||
return queryResults;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public Collection<Node> getNodeAssocSources(final Node targetNode, final QName assocTypeQName)
|
|
||||||
{
|
|
||||||
HibernateCallback callback = new HibernateCallback()
|
|
||||||
{
|
|
||||||
public Object doInHibernate(Session session)
|
|
||||||
{
|
|
||||||
Query query = session.getNamedQuery(HibernateNodeDaoServiceImpl.QUERY_GET_NODE_ASSOC_SOURCES);
|
|
||||||
query.setEntity("targetNode", targetNode)
|
|
||||||
.setString("assocTypeQName", assocTypeQName.toString());
|
|
||||||
return query.list();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
List<Node> queryResults = (List) getHibernateTemplate().execute(callback);
|
|
||||||
// done
|
|
||||||
return queryResults;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteNodeAssoc(NodeAssoc assoc)
|
public void deleteNodeAssoc(NodeAssoc assoc)
|
||||||
|
Reference in New Issue
Block a user