Reworked MapEntry schema for better cache performance.

Set Attribute entities to be not lazy.
Additional AttributeService testing.
Fixed DoubleAttributeImpl's declaration to implement DoubleAttribute.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5566 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2007-04-26 15:53:13 +00:00
parent 2888a3737c
commit e73ce68e8f
19 changed files with 150 additions and 107 deletions

View File

@@ -109,7 +109,7 @@ public class AttributeDAOHibernate extends HibernateDaoSupport implements
{
AttrQueryHelper helper = new AttrQueryHelperImpl();
String predicate = query.getPredicate(helper);
String fullQuery = "from MapEntryImpl me where me.map = :map and " + predicate;
String fullQuery = "from MapEntryImpl me where me.key.map = :map and " + predicate;
Query hQuery = getSession().createQuery(fullQuery);
hQuery.setEntity("map", map);
for (Map.Entry<String, String> param : helper.getParameters().entrySet())
@@ -120,7 +120,7 @@ public class AttributeDAOHibernate extends HibernateDaoSupport implements
List<Pair<String, Attribute>> result = new ArrayList<Pair<String, Attribute>>();
for (MapEntry entry : hits)
{
result.add(new Pair<String, Attribute>(entry.getKey(), entry.getAttribute()));
result.add(new Pair<String, Attribute>(entry.getKey().getKey(), entry.getAttribute()));
}
return result;
}

View File

@@ -7,7 +7,7 @@
<class table="alf_attributes" abstract="true"
name="AttributeImpl" proxy="Attribute"
optimistic-lock="version"
lazy="true">
lazy="false">
<cache usage="read-write"/>
<id name="id" column="id" type="long">
<generator class="native"/>
@@ -17,76 +17,73 @@
<many-to-one name="acl" column="acl_id" foreign-key="fk_attributes_n_acl"
class="org.alfresco.repo.domain.hibernate.DbAccessControlListImpl"/>
<!-- A boolean valued attribute -->
<subclass name="BooleanAttributeImpl" proxy="BooleanAttribute" lazy="true"
<subclass name="BooleanAttributeImpl" proxy="BooleanAttribute" lazy="false"
discriminator-value="O">
<property name="booleanValue" column="bool_value" type="boolean"/>
</subclass>
<!-- A byte valued attribute -->
<subclass name="ByteAttributeImpl" proxy="ByteAttribute" lazy="true"
<subclass name="ByteAttributeImpl" proxy="ByteAttribute" lazy="false"
discriminator-value="Y">
<property name="byteValue" column="byte_value" type="byte"/>
</subclass>
<!-- A short valued attribute -->
<subclass name="ShortAttributeImpl" proxy="ShortAttribute" lazy="true"
<subclass name="ShortAttributeImpl" proxy="ShortAttribute" lazy="false"
discriminator-value="H">
<property name="shortValue" column="short_value" type="short"/>
</subclass>
<!-- An integer valued attribute. -->
<subclass name="IntAttributeImpl" proxy="IntAttribute" lazy="true"
<subclass name="IntAttributeImpl" proxy="IntAttribute" lazy="false"
discriminator-value="I">
<property name="intValue" column="int_value" type="int"/>
</subclass>
<!-- A long valued attribute -->
<subclass name="LongAttributeImpl" proxy="LongAttribute" lazy="true"
<subclass name="LongAttributeImpl" proxy="LongAttribute" lazy="false"
discriminator-value="L">
<property name="longValue" column="long_value" type="long"/>
</subclass>
<!-- A float valued attribute -->
<subclass name="FloatAttributeImpl" proxy="FloatAttribute" lazy="true"
<subclass name="FloatAttributeImpl" proxy="FloatAttribute" lazy="false"
discriminator-value="F">
<property name="floatValue" column="float_value" type="float"/>
</subclass>
<!-- A double valued attribute -->
<subclass name="DoubleAttributeImpl" proxy="DoubleAttribute" lazy="true"
<subclass name="DoubleAttributeImpl" proxy="DoubleAttribute" lazy="false"
discriminator-value="D">
<property name="doubleValue" column="double_value" type="double"/>
</subclass>
<!-- A string valued attribute -->
<subclass name="StringAttributeImpl" proxy="StringAttribute" lazy="true"
<subclass name="StringAttributeImpl" proxy="StringAttribute" lazy="false"
discriminator-value="S">
<property name="stringValue" column="string_value" type="string"
length="512"/>
</subclass>
<!-- A serializable attribute -->
<subclass name="SerializableAttributeImpl" proxy="SerializableAttribute" lazy="true"
<subclass name="SerializableAttributeImpl" proxy="SerializableAttribute" lazy="false"
discriminator-value="E">
<property name="serializableValue" column="serializable_value" lazy="true"
<property name="serializableValue" column="serializable_value" lazy="false"
length="8192"/>
</subclass>
<!-- A map attribute -->
<subclass name="MapAttributeImpl" proxy="MapAttribute" lazy="true"
<subclass name="MapAttributeImpl" proxy="MapAttribute" lazy="false"
discriminator-value="M">
</subclass>
<!-- A List class -->
<subclass name="ListAttributeImpl" proxy="ListAttribute" lazy="true"
<subclass name="ListAttributeImpl" proxy="ListAttribute" lazy="false"
discriminator-value="T">
</subclass>
</class>
<class name="GlobalAttributeEntryImpl" proxy="GlobalAttributeEntry" table="alf_global_attributes">
<class name="GlobalAttributeEntryImpl" proxy="GlobalAttributeEntry" table="alf_global_attributes" lazy="false">
<cache usage="read-write"/>
<id name="name" type="string" length="160"/>
<many-to-one class="AttributeImpl" name="attribute" unique="true"/>
<many-to-one class="AttributeImpl" name="attribute" unique="true" lazy="false"/>
</class>
<class name="MapEntryImpl" proxy="MapEntry" lazy="false" table="alf_map_attribute_entries">
<cache usage="read-write"/>
<id name="id" column="id" type="long">
<generator class="native"/>
</id>
<natural-id>
<many-to-one class="MapAttributeImpl" name="map" column="map_id"/>
<property name="key" type="string" length="160" column="mkey" index="map_key_index"/>
</natural-id>
<many-to-one class="AttributeImpl" name="attribute" column="attribute_id"/>
<composite-id name="key" class="MapEntryKey">
<key-many-to-one class="MapAttributeImpl" name="map" column="map_id"/>
<key-property name="key" type="string" length="160" column="mkey"/>
</composite-id>
<many-to-one class="AttributeImpl" name="attribute" column="attribute_id" lazy="false"/>
</class>
<class name="ListEntryImpl" proxy="ListEntry" lazy="false" table="alf_list_attribute_entries">
<cache usage="read-write"/>
@@ -94,6 +91,6 @@
<key-many-to-one class="ListAttributeImpl" name="list" column="list_id"/>
<key-property name="index" type="int" column="mindex"/>
</composite-id>
<many-to-one class="AttributeImpl" name="attribute" column="attribute_id"/>
<many-to-one class="AttributeImpl" name="attribute" column="attribute_id" lazy="false"/>
</class>
</hibernate-mapping>

View File

@@ -30,6 +30,8 @@ import java.util.List;
import org.alfresco.repo.attributes.MapAttribute;
import org.alfresco.repo.attributes.MapEntry;
import org.alfresco.repo.attributes.MapEntryDAO;
import org.alfresco.repo.attributes.MapEntryImpl;
import org.alfresco.repo.attributes.MapEntryKey;
import org.hibernate.Query;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
@@ -53,7 +55,7 @@ public class MapEntryDAOHibernate extends HibernateDaoSupport implements
*/
public void delete(MapAttribute mapAttr)
{
Query query = getSession().createQuery("delete from MapEntryImpl me where me.map = :map");
Query query = getSession().createQuery("delete from MapEntryImpl me where me.key.map = :map");
query.setEntity("map", mapAttr);
query.executeUpdate();
}
@@ -61,12 +63,9 @@ public class MapEntryDAOHibernate extends HibernateDaoSupport implements
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.MapEntryDAO#get(org.alfresco.repo.attributes.MapAttribute, java.lang.String)
*/
public MapEntry get(MapAttribute mapAttr, String key)
public MapEntry get(MapEntryKey key)
{
Query query = getSession().createQuery("from MapEntryImpl me where me.map = :map and me.key = :key");
query.setEntity("map", mapAttr);
query.setParameter("key", key);
return (MapEntry)query.uniqueResult();
return (MapEntry)getSession().get(MapEntryImpl.class, key);
}
/* (non-Javadoc)
@@ -75,7 +74,7 @@ public class MapEntryDAOHibernate extends HibernateDaoSupport implements
@SuppressWarnings("unchecked")
public List<MapEntry> get(MapAttribute mapAttr)
{
Query query = getSession().createQuery("from MapEntryImpl me where me.map = :map");
Query query = getSession().createQuery("from MapEntryImpl me where me.key.map = :map");
query.setEntity("map", mapAttr);
return (List<MapEntry>)query.list();
}
@@ -93,7 +92,7 @@ public class MapEntryDAOHibernate extends HibernateDaoSupport implements
*/
public int size(MapAttribute mapAttr)
{
Query query = getSession().createQuery("select count(me) from MapEntryImpl me where me.map = :map");
Query query = getSession().createQuery("select count(*) from MapEntryImpl me where me.key.map = :map");
query.setEntity("map", mapAttr);
return ((Long)query.uniqueResult()).intValue();
}