mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-16 17:55:15 +00:00
Fixed flush mode for queries to get child associations.
This had the side-effect of fixing the ADMLuceneTest that was failing during in-transaction deletions of child associations. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5828 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
parent
6675ba0e6e
commit
dec1de7f34
@ -32,7 +32,6 @@ import java.util.Collection;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.zip.CRC32;
|
import java.util.zip.CRC32;
|
||||||
|
|
||||||
@ -72,18 +71,13 @@ import org.alfresco.service.namespace.QName;
|
|||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.hibernate.FlushMode;
|
|
||||||
import org.hibernate.LockMode;
|
|
||||||
import org.hibernate.ObjectDeletedException;
|
import org.hibernate.ObjectDeletedException;
|
||||||
import org.hibernate.Query;
|
import org.hibernate.Query;
|
||||||
import org.hibernate.ScrollMode;
|
import org.hibernate.ScrollMode;
|
||||||
import org.hibernate.ScrollableResults;
|
import org.hibernate.ScrollableResults;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.exception.LockAcquisitionException;
|
|
||||||
import org.springframework.dao.ConcurrencyFailureException;
|
|
||||||
import org.springframework.dao.DataAccessException;
|
import org.springframework.dao.DataAccessException;
|
||||||
import org.springframework.dao.DataIntegrityViolationException;
|
import org.springframework.dao.DataIntegrityViolationException;
|
||||||
import org.springframework.dao.DeadlockLoserDataAccessException;
|
|
||||||
import org.springframework.orm.hibernate3.HibernateCallback;
|
import org.springframework.orm.hibernate3.HibernateCallback;
|
||||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||||
|
|
||||||
@ -95,7 +89,6 @@ import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
|||||||
public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements NodeDaoService, TransactionalDao
|
public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements NodeDaoService, TransactionalDao
|
||||||
{
|
{
|
||||||
private static final String QUERY_GET_ALL_STORES = "store.GetAllStores";
|
private static final String QUERY_GET_ALL_STORES = "store.GetAllStores";
|
||||||
private static final String UPDATE_SET_CHILD_ASSOC_NAME = "node.updateChildAssocName";
|
|
||||||
private static final String QUERY_GET_PRIMARY_CHILD_NODE_STATUSES = "node.GetPrimaryChildNodeStatuses";
|
private static final String QUERY_GET_PRIMARY_CHILD_NODE_STATUSES = "node.GetPrimaryChildNodeStatuses";
|
||||||
private static final String QUERY_GET_CHILD_ASSOCS = "node.GetChildAssocs";
|
private static final String QUERY_GET_CHILD_ASSOCS = "node.GetChildAssocs";
|
||||||
private static final String QUERY_GET_CHILD_ASSOCS_BY_ALL = "node.GetChildAssocsByAll";
|
private static final String QUERY_GET_CHILD_ASSOCS_BY_ALL = "node.GetChildAssocsByAll";
|
||||||
@ -115,12 +108,9 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
|
|||||||
|
|
||||||
/** a uuid identifying this unique instance */
|
/** a uuid identifying this unique instance */
|
||||||
private final String uuid;
|
private final String uuid;
|
||||||
/** the number of lock retries against the parent node to ensure child uniqueness */
|
|
||||||
private int maxLockRetries;
|
|
||||||
|
|
||||||
private static TransactionAwareSingleton<Long> serverIdSingleton = new TransactionAwareSingleton<Long>();
|
private static TransactionAwareSingleton<Long> serverIdSingleton = new TransactionAwareSingleton<Long>();
|
||||||
private final String ipAddress;
|
private final String ipAddress;
|
||||||
private Random randomWaitTime;
|
|
||||||
|
|
||||||
/** used for debugging */
|
/** used for debugging */
|
||||||
private Set<String> changeTxnIdSet;
|
private Set<String> changeTxnIdSet;
|
||||||
@ -131,7 +121,6 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
|
|||||||
public HibernateNodeDaoServiceImpl()
|
public HibernateNodeDaoServiceImpl()
|
||||||
{
|
{
|
||||||
this.uuid = GUID.generate();
|
this.uuid = GUID.generate();
|
||||||
this.maxLockRetries = 20;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ipAddress = InetAddress.getLocalHost().getHostAddress();
|
ipAddress = InetAddress.getLocalHost().getHostAddress();
|
||||||
@ -140,7 +129,6 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
|
|||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Failed to get server IP address", e);
|
throw new AlfrescoRuntimeException("Failed to get server IP address", e);
|
||||||
}
|
}
|
||||||
randomWaitTime = new Random(System.currentTimeMillis());
|
|
||||||
|
|
||||||
changeTxnIdSet = new HashSet<String>(0);
|
changeTxnIdSet = new HashSet<String>(0);
|
||||||
}
|
}
|
||||||
@ -170,16 +158,6 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
|
|||||||
return uuid.hashCode();
|
return uuid.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the maximum number of retries when attempting to get a lock on a parent node
|
|
||||||
*
|
|
||||||
* @param maxLockRetries the retry count
|
|
||||||
*/
|
|
||||||
public void setMaxLockRetries(int maxLockRetries)
|
|
||||||
{
|
|
||||||
this.maxLockRetries = maxLockRetries;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets/creates the <b>server</b> instance to use for the life of this instance
|
* Gets/creates the <b>server</b> instance to use for the life of this instance
|
||||||
*/
|
*/
|
||||||
@ -718,8 +696,7 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
|
|||||||
{
|
{
|
||||||
Query query = session
|
Query query = session
|
||||||
.getNamedQuery(HibernateNodeDaoServiceImpl.QUERY_GET_PRIMARY_CHILD_NODE_STATUSES)
|
.getNamedQuery(HibernateNodeDaoServiceImpl.QUERY_GET_PRIMARY_CHILD_NODE_STATUSES)
|
||||||
.setLong("parentId", parentNode.getId())
|
.setLong("parentId", parentNode.getId());
|
||||||
.setFlushMode(FlushMode.MANUAL);
|
|
||||||
return query.list();
|
return query.list();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -736,7 +713,6 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
|
|||||||
{
|
{
|
||||||
Query query = session
|
Query query = session
|
||||||
.getNamedQuery(HibernateNodeDaoServiceImpl.QUERY_GET_CHILD_ASSOCS)
|
.getNamedQuery(HibernateNodeDaoServiceImpl.QUERY_GET_CHILD_ASSOCS)
|
||||||
.setFlushMode(FlushMode.MANUAL)
|
|
||||||
.setLong("parentId", parentNode.getId());
|
.setLong("parentId", parentNode.getId());
|
||||||
return query.list();
|
return query.list();
|
||||||
}
|
}
|
||||||
@ -754,7 +730,6 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
|
|||||||
{
|
{
|
||||||
Query query = session
|
Query query = session
|
||||||
.getNamedQuery(HibernateNodeDaoServiceImpl.QUERY_GET_CHILD_ASSOC_REFS)
|
.getNamedQuery(HibernateNodeDaoServiceImpl.QUERY_GET_CHILD_ASSOC_REFS)
|
||||||
.setFlushMode(FlushMode.MANUAL)
|
|
||||||
.setLong("parentId", parentNode.getId());
|
.setLong("parentId", parentNode.getId());
|
||||||
return query.list();
|
return query.list();
|
||||||
}
|
}
|
||||||
@ -774,7 +749,6 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
|
|||||||
{
|
{
|
||||||
Query query = session
|
Query query = session
|
||||||
.getNamedQuery(HibernateNodeDaoServiceImpl.QUERY_GET_CHILD_ASSOC_REFS_BY_QNAME)
|
.getNamedQuery(HibernateNodeDaoServiceImpl.QUERY_GET_CHILD_ASSOC_REFS_BY_QNAME)
|
||||||
.setFlushMode(FlushMode.MANUAL)
|
|
||||||
.setLong("parentId", parentNode.getId())
|
.setLong("parentId", parentNode.getId())
|
||||||
.setParameter("childAssocQName", assocQName);
|
.setParameter("childAssocQName", assocQName);
|
||||||
return query.list();
|
return query.list();
|
||||||
|
@ -50,7 +50,6 @@ import org.alfresco.repo.dictionary.DictionaryDAO;
|
|||||||
import org.alfresco.repo.dictionary.DictionaryNamespaceComponent;
|
import org.alfresco.repo.dictionary.DictionaryNamespaceComponent;
|
||||||
import org.alfresco.repo.dictionary.M2Model;
|
import org.alfresco.repo.dictionary.M2Model;
|
||||||
import org.alfresco.repo.dictionary.NamespaceDAOImpl;
|
import org.alfresco.repo.dictionary.NamespaceDAOImpl;
|
||||||
import org.alfresco.repo.domain.hibernate.SessionSizeResourceManager;
|
|
||||||
import org.alfresco.repo.node.BaseNodeServiceTest;
|
import org.alfresco.repo.node.BaseNodeServiceTest;
|
||||||
import org.alfresco.repo.search.MLAnalysisMode;
|
import org.alfresco.repo.search.MLAnalysisMode;
|
||||||
import org.alfresco.repo.search.QueryParameterDefImpl;
|
import org.alfresco.repo.search.QueryParameterDefImpl;
|
||||||
@ -1039,8 +1038,6 @@ public class ADMLuceneTest extends TestCase
|
|||||||
{
|
{
|
||||||
public Object execute() throws Throwable
|
public Object execute() throws Throwable
|
||||||
{
|
{
|
||||||
// Disable resource management
|
|
||||||
SessionSizeResourceManager.setDisableInTransaction();
|
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 100; i++)
|
||||||
{
|
{
|
||||||
HashSet<ChildAssociationRef> refs = new HashSet<ChildAssociationRef>();
|
HashSet<ChildAssociationRef> refs = new HashSet<ChildAssociationRef>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user