mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Fixed issue where node with specific UUID is recreated in the same transaction as it is deleted in
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2747 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -216,6 +216,27 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
|
|||||||
public Node newNode(Store store, String uuid, QName nodeTypeQName) throws InvalidTypeException
|
public Node newNode(Store store, String uuid, QName nodeTypeQName) throws InvalidTypeException
|
||||||
{
|
{
|
||||||
NodeKey key = new NodeKey(store.getKey(), uuid);
|
NodeKey key = new NodeKey(store.getKey(), uuid);
|
||||||
|
|
||||||
|
// create (or reuse) the mandatory node status
|
||||||
|
NodeStatus status = (NodeStatus) getHibernateTemplate().get(NodeStatusImpl.class, key);
|
||||||
|
if (status == null)
|
||||||
|
{
|
||||||
|
status = new NodeStatusImpl();
|
||||||
|
status.setKey(key);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// The node existed at some point.
|
||||||
|
// Although unlikely, it is possible that the node was deleted in this transaction.
|
||||||
|
// If that is the case, then the session has to be flushed so that the database
|
||||||
|
// constraints aren't violated as the node creation will write to the database to
|
||||||
|
// get an ID
|
||||||
|
if (status.getChangeTxnId().equals(AlfrescoTransactionSupport.getTransactionId()))
|
||||||
|
{
|
||||||
|
// flush
|
||||||
|
getHibernateTemplate().flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// build a concrete node based on a bootstrap type
|
// build a concrete node based on a bootstrap type
|
||||||
Node node = new NodeImpl();
|
Node node = new NodeImpl();
|
||||||
@@ -225,14 +246,7 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
|
|||||||
node.setTypeQName(nodeTypeQName);
|
node.setTypeQName(nodeTypeQName);
|
||||||
// persist the node
|
// persist the node
|
||||||
getHibernateTemplate().save(node);
|
getHibernateTemplate().save(node);
|
||||||
|
|
||||||
// create (or reuse) the mandatory node status
|
|
||||||
NodeStatus status = (NodeStatus) getHibernateTemplate().get(NodeStatusImpl.class, key);
|
|
||||||
if (status == null)
|
|
||||||
{
|
|
||||||
status = new NodeStatusImpl();
|
|
||||||
status.setKey(key);
|
|
||||||
}
|
|
||||||
// set required status properties
|
// set required status properties
|
||||||
status.setNode(node);
|
status.setNode(node);
|
||||||
status.setChangeTxnId(AlfrescoTransactionSupport.getTransactionId());
|
status.setChangeTxnId(AlfrescoTransactionSupport.getTransactionId());
|
||||||
@@ -322,6 +336,7 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
|
|||||||
assoc.setTypeQName(assocTypeQName);
|
assoc.setTypeQName(assocTypeQName);
|
||||||
assoc.setIsPrimary(isPrimary);
|
assoc.setIsPrimary(isPrimary);
|
||||||
assoc.setQname(qname);
|
assoc.setQname(qname);
|
||||||
|
// assoc.setIsArchived(false);
|
||||||
assoc.buildAssociation(parentNode, childNode);
|
assoc.buildAssociation(parentNode, childNode);
|
||||||
// persist
|
// persist
|
||||||
getHibernateTemplate().save(assoc);
|
getHibernateTemplate().save(assoc);
|
||||||
@@ -434,6 +449,7 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
|
|||||||
{
|
{
|
||||||
NodeAssoc assoc = new NodeAssocImpl();
|
NodeAssoc assoc = new NodeAssocImpl();
|
||||||
assoc.setTypeQName(assocTypeQName);
|
assoc.setTypeQName(assocTypeQName);
|
||||||
|
// assoc.setIsArchived(false);
|
||||||
assoc.buildAssociation(sourceNode, targetNode);
|
assoc.buildAssociation(sourceNode, targetNode);
|
||||||
// persist
|
// persist
|
||||||
getHibernateTemplate().save(assoc);
|
getHibernateTemplate().save(assoc);
|
||||||
|
Reference in New Issue
Block a user