Added 'version' column to ADM entities

- A patch will assign initial version values to the entities
 - Deprecated TransactionUtil in favour of the RetryingTransactionHelper
 - Renamed RetryingTransactionHelper.Callback to RetryingTransactionHelper.RetryingTransactionCallback
   The name Callback clashes with many other classes in the classpath
 - Moved loads of components to be included in the retry behaviour
Duplicate name checks
 - This is done using a query, but the entity update is not written to the database early
 - Concurrent adds of the same-named child node will only fail at the end of the transaction
 - TODO: Detect the duplicate violation during transaction retrying
Workaround for ADMLuceneTest
 - Disable session size resource management during tests


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5823 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-06-01 12:40:17 +00:00
parent bbbd18923f
commit 819c7084a2
45 changed files with 818 additions and 230 deletions

View File

@@ -49,6 +49,7 @@ import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.repo.transaction.TransactionListenerAdapter;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.BaseSpringTest;
@@ -178,6 +179,8 @@ public class HibernateNodeTest extends BaseSpringTest
// Sybase
// expected
}
// Just clear out any pending changes
getSession().clear();
}
/**
@@ -584,4 +587,58 @@ public class HibernateNodeTest extends BaseSpringTest
getSession().flush();
getSession().clear();
}
public void testDeletesAndFlush() throws Exception
{
// Create parent node
Node parentNode = new NodeImpl();
parentNode.setStore(store);
parentNode.setUuid(GUID.generate());
parentNode.setTypeQName(ContentModel.TYPE_CONTAINER);
Long nodeIdOne = (Long) getSession().save(parentNode);
// Create child node
Node childNode = new NodeImpl();
childNode.setStore(store);
childNode.setUuid(GUID.generate());
childNode.setTypeQName(ContentModel.TYPE_CONTENT);
Long nodeIdTwo = (Long) getSession().save(childNode);
// Get them into the database
getSession().flush();
// Now create a loads of associations
int assocCount = 1000;
List<Long> assocIds = new ArrayList<Long>(assocCount);
for (int i = 0; i < assocCount; i++)
{
ChildAssoc assoc = new ChildAssocImpl();
assoc.buildAssociation(parentNode, childNode);
assoc.setIsPrimary(false);
assoc.setTypeQName(QName.createQName(null, "TYPE"));
assoc.setQname(QName.createQName(null, "" + System.nanoTime()));
assoc.setChildNodeName(GUID.generate()); // It must be unique
assoc.setChildNodeNameCrc(-1L);
Long assocId = (Long) getSession().save(assoc);
assocIds.add(assocId);
}
// Flush and clear the lot
getSession().flush();
getSession().clear();
// Now we delete the entities, flushing and clearing every 100 deletes
int count = 0;
for (Long assocId : assocIds)
{
// Load the entity
ChildAssoc assoc = (ChildAssoc) getSession().get(ChildAssocImpl.class, assocId);
assertNotNull("Entity should exist", assoc);
getSession().delete(assoc);
// Do we flush and clear
if (count % 100 == 0)
{
getSession().flush();
getSession().clear();
}
count++;
}
}
}