Rejiggered ChildEntry and its mapping, for considerably better performance. Actually

it was kind of a Doh! moment.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4336 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-11-12 13:53:29 +00:00
parent ae4ba1126e
commit fa0bb97dc1
13 changed files with 344 additions and 320 deletions

View File

@@ -135,19 +135,15 @@
<property name="tag" type="string" length="255" column="tag"/>
<property name="description" type="string" length="8192" column="description"/>
</class>
<class name="ChildEntryImpl" proxy="ChildEntry" table="avm_child_entries" optimistic-lock="version">
<cache usage="read-write"/>
<id name="id" column="id" type="long">
<generator class="native"/>
</id>
<natural-id>
<property name="name" type="string" length="160" column="name" index="child_name_index" not-null="true"/>
<many-to-one name="parent" column="parent_id" class="DirectoryNodeImpl" not-null="true"/>
</natural-id>
<version name="vers" column="vers" type="long"/>
<many-to-one name="child" column="child_id" class="AVMNodeImpl"
not-null="true"/>
</class>
<class name="ChildEntryImpl" proxy="ChildEntry" table="avm_child_entries">
<cache usage="read-write"/>
<composite-id name="key" class="ChildKey">
<key-many-to-one name="parent" column="parent_id" class="DirectoryNodeImpl"/>
<key-property name="name" column="name" type="string" length="160"/>
</composite-id>
<many-to-one name="child" column="child_id" class="AVMNodeImpl"
not-null="true"/>
</class>
<class name="HistoryLinkImpl" proxy="HistoryLink" table="avm_history_links">
<composite-id>
<key-many-to-one name="ancestor" class="AVMNodeImpl" column="ancestor"/>
@@ -204,31 +200,10 @@
<many-to-one name="node" class="AVMNodeImpl" column="node_id"/>
<property name="name" column="qname" type="QName" length="200"/>
</class>
<query name="ChildEntry.ByNameParent">
<![CDATA[
from ChildEntryImpl ce
where
ce.name = :name and ce.parent = :parent
]]>
</query>
<query name="ChildEntry.ByParent">
<![CDATA[
from ChildEntryImpl ce
where
ce.parent = :parent
]]>
</query>
<query name="ChildEntry.ByParentChild">
<![CDATA[
from ChildEntryImpl ce
where
ce.child = :child and ce.parent = :parent
]]>
</query>
<query name="ChildEntry.DeleteByParent">
<![CDATA[
delete ChildEntryImpl ce
where ce.parent = :parent
where ce.key.parent = :parent
]]>
</query>
<query name="AVMNode.GetNewInStore">

View File

@@ -21,7 +21,9 @@ import java.util.List;
import org.alfresco.repo.avm.AVMNode;
import org.alfresco.repo.avm.ChildEntry;
import org.alfresco.repo.avm.ChildEntryImpl;
import org.alfresco.repo.avm.ChildEntryDAO;
import org.alfresco.repo.avm.ChildKey;
import org.alfresco.repo.avm.DirectoryNode;
import org.hibernate.Query;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
@@ -56,13 +58,9 @@ class ChildEntryDAOHibernate extends HibernateDaoSupport implements
* @param parent The parent to look in.
* @return The ChildEntry or null if not foun.
*/
public ChildEntry getByNameParent(String name, DirectoryNode parent)
public ChildEntry get(ChildKey key)
{
Query query = getSession().createQuery(
"from ChildEntryImpl ce where ce.name = :name and ce.parent = :parent");
query.setString("name", name);
query.setEntity("parent", parent);
return (ChildEntry)query.uniqueResult();
return (ChildEntry)getSession().get(ChildEntryImpl.class, key);
}
/**
@@ -73,7 +71,8 @@ class ChildEntryDAOHibernate extends HibernateDaoSupport implements
@SuppressWarnings("unchecked")
public List<ChildEntry> getByParent(DirectoryNode parent)
{
Query query = getSession().getNamedQuery("ChildEntry.ByParent");
Query query =
getSession().createQuery("from ChildEntryImpl ce where ce.key.parent = :parent");
query.setEntity("parent", parent);
return (List<ChildEntry>)query.list();
}
@@ -86,7 +85,9 @@ class ChildEntryDAOHibernate extends HibernateDaoSupport implements
*/
public ChildEntry getByParentChild(DirectoryNode parent, AVMNode child)
{
Query query = getSession().getNamedQuery("ChildEntry.ByParentChild");
Query query =
getSession().createQuery("from ChildEntryImpl ce where ce.key.parent = :parent " +
"and ce.child = :child");
query.setEntity("parent", parent);
query.setEntity("child", child);
return (ChildEntry)query.uniqueResult();
@@ -124,6 +125,7 @@ class ChildEntryDAOHibernate extends HibernateDaoSupport implements
getSession().delete(child);
}
// TODO Does this have dangerous interactions with the cache?
/**
* Delete all children of the given parent.
* @param parent The parent.