Refactored persistence for AVM. I'm guessing because I dropped a number of

unnecessary flushes seems about 20% snappier.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3296 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-07-11 09:32:13 +00:00
parent a58a3c4f53
commit d0b5b14af1
46 changed files with 2172 additions and 506 deletions

View File

@@ -17,14 +17,11 @@
package org.alfresco.repo.avm;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import org.hibernate.Session;
/**
* A plain directory. No monkey tricks except for possiblyCopy.
* @author britt
@@ -40,7 +37,7 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
public PlainDirectoryNodeImpl(Repository repo)
{
super(repo.getSuperRepository().issueID(), repo);
repo.getSuperRepository().getSession().save(this);
AVMContext.fgInstance.fAVMNodeDAO.save(this);
}
/**
@@ -60,16 +57,15 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
Repository repos)
{
super(repos.getSuperRepository().issueID(), repos);
Session sess = repos.getSuperRepository().getSession();
sess.save(this);
sess.flush();
AVMContext.fgInstance.fAVMNodeDAO.save(this);
// TODO Something about this. sess.flush();
for (ChildEntry child : other.getChildren())
{
ChildEntry newChild = new ChildEntryImpl(child.getName(),
this,
child.getChild());
sess.save(newChild);
sess.flush();
AVMContext.fgInstance.fChildEntryDAO.save(newChild);
// TODO Something about this: sess.flush();
}
}
@@ -172,7 +168,7 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
ChildEntry entry = getChild(name, true);
if (entry != null)
{
SuperRepository.GetInstance().getSession().delete(entry);
AVMContext.fgInstance.fChildEntryDAO.delete(entry);
}
}
@@ -183,18 +179,16 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
*/
public void putChild(String name, AVMNode node)
{
Session sess = SuperRepository.GetInstance().getSession();
// sess.lock(this, LockMode.UPGRADE);
ChildEntry entry = new ChildEntryImpl(name, this, node);
ChildEntry existing = (ChildEntry)sess.get(ChildEntryImpl.class, (Serializable)entry);
ChildEntry existing = AVMContext.fgInstance.fChildEntryDAO.getByNameParent(name, this);
if (existing != null)
{
existing.setChild(node);
sess.flush(); // TODO Should we or shouldn't we?
AVMContext.fgInstance.fChildEntryDAO.update(existing);
}
else
{
sess.save(entry);
ChildEntry entry = new ChildEntryImpl(name, this, node);
AVMContext.fgInstance.fChildEntryDAO.save(entry);
}
}