mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Ensure initialization of the Hibernate association bags
- If uninitialized (e.g. by a size() call), then the new assocations added are queued for addition - These then become duplicated within the session (not the DB) and appear as duplicate associations during integrity checking Fixed test git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2741 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -46,6 +46,11 @@ public class ChildAssocImpl implements ChildAssoc
|
|||||||
// add the forward associations
|
// add the forward associations
|
||||||
this.setParent(parentNode);
|
this.setParent(parentNode);
|
||||||
this.setChild(childNode);
|
this.setChild(childNode);
|
||||||
|
// Force initialization of the inverse collections
|
||||||
|
// so that we don't queue additions to them.
|
||||||
|
// This can go if we move to set-based collections
|
||||||
|
parentNode.getChildAssocs().size();
|
||||||
|
childNode.getParentAssocs().size();
|
||||||
// add the inverse associations
|
// add the inverse associations
|
||||||
parentNode.getChildAssocs().add(this);
|
parentNode.getChildAssocs().add(this);
|
||||||
childNode.getParentAssocs().add(this);
|
childNode.getParentAssocs().add(this);
|
||||||
|
@@ -263,6 +263,7 @@ public class HibernateNodeTest extends BaseSpringTest
|
|||||||
// make a content node
|
// make a content node
|
||||||
Node contentNode = new NodeImpl();
|
Node contentNode = new NodeImpl();
|
||||||
contentNode.setStore(store);
|
contentNode.setStore(store);
|
||||||
|
contentNode.setUuid(GUID.generate());
|
||||||
contentNode.setTypeQName(ContentModel.TYPE_CONTENT);
|
contentNode.setTypeQName(ContentModel.TYPE_CONTENT);
|
||||||
Serializable contentNodeId = getSession().save(contentNode);
|
Serializable contentNodeId = getSession().save(contentNode);
|
||||||
|
|
||||||
|
@@ -44,6 +44,11 @@ public class NodeAssocImpl implements NodeAssoc
|
|||||||
// add the forward associations
|
// add the forward associations
|
||||||
this.setTarget(targetNode);
|
this.setTarget(targetNode);
|
||||||
this.setSource(sourceNode);
|
this.setSource(sourceNode);
|
||||||
|
// Force initialization of the inverse collections
|
||||||
|
// so that we don't queue additions to them.
|
||||||
|
// This can go if we move to set-based collections
|
||||||
|
sourceNode.getSourceNodeAssocs().size();
|
||||||
|
targetNode.getTargetNodeAssocs().size();
|
||||||
// add the inverse associations
|
// add the inverse associations
|
||||||
sourceNode.getTargetNodeAssocs().add(this);
|
sourceNode.getTargetNodeAssocs().add(this);
|
||||||
targetNode.getSourceNodeAssocs().add(this);
|
targetNode.getSourceNodeAssocs().add(this);
|
||||||
|
Reference in New Issue
Block a user