mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
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:
@@ -65,7 +65,7 @@ public class AttrQueryTest extends TestCase
|
|||||||
String predicate = query.getPredicate(fHelper);
|
String predicate = query.getPredicate(fHelper);
|
||||||
System.out.println(predicate);
|
System.out.println(predicate);
|
||||||
System.out.println(fHelper.getParameters());
|
System.out.println(fHelper.getParameters());
|
||||||
assertEquals("((me.key > :name0 and me.key < :name1) or (not me.key like :name2))",
|
assertEquals("((me.key.key > :name0 and me.key.key < :name1) or (not me.key.key like :name2))",
|
||||||
predicate);
|
predicate);
|
||||||
assertEquals("cat", fHelper.getParameters().get("name0"));
|
assertEquals("cat", fHelper.getParameters().get("name0"));
|
||||||
assertEquals("hat", fHelper.getParameters().get("name1"));
|
assertEquals("hat", fHelper.getParameters().get("name1"));
|
||||||
|
@@ -306,6 +306,15 @@ public class AttributeServiceTest extends TestCase
|
|||||||
Attribute replace = new StringAttributeValue("String");
|
Attribute replace = new StringAttributeValue("String");
|
||||||
fService.setAttribute("dummy", 2, replace);
|
fService.setAttribute("dummy", 2, replace);
|
||||||
assertEquals("String", fService.getAttribute("dummy/2").getStringValue());
|
assertEquals("String", fService.getAttribute("dummy/2").getStringValue());
|
||||||
|
MapAttribute map = new MapAttributeValue();
|
||||||
|
map.put("list", list);
|
||||||
|
MapAttribute subMap = new MapAttributeValue();
|
||||||
|
subMap.put("a", new StringAttributeValue("polyester"));
|
||||||
|
subMap.put("b", new StringAttributeValue("donuts"));
|
||||||
|
subMap.put("c", new StringAttributeValue("brutality"));
|
||||||
|
list.add(subMap);
|
||||||
|
fService.setAttribute("", "map", map);
|
||||||
|
assertEquals("donuts", fService.getAttribute("map/list/5/b").getStringValue());
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@@ -31,7 +31,7 @@ import org.alfresco.repo.avm.AVMDAOs;
|
|||||||
* Persistent double attribute implementation.
|
* Persistent double attribute implementation.
|
||||||
* @author britt
|
* @author britt
|
||||||
*/
|
*/
|
||||||
public class DoubleAttributeImpl extends AttributeImpl implements Attribute
|
public class DoubleAttributeImpl extends AttributeImpl implements DoubleAttribute
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 6615023606094278263L;
|
private static final long serialVersionUID = 6615023606094278263L;
|
||||||
|
|
||||||
|
@@ -33,6 +33,8 @@ import java.io.Serializable;
|
|||||||
*/
|
*/
|
||||||
public class ListEntryKey implements Serializable
|
public class ListEntryKey implements Serializable
|
||||||
{
|
{
|
||||||
|
private static final long serialVersionUID = 7314576560198411815L;
|
||||||
|
|
||||||
private ListAttribute fList;
|
private ListAttribute fList;
|
||||||
|
|
||||||
private int fIndex;
|
private int fIndex;
|
||||||
|
@@ -120,7 +120,8 @@ public class MapAttributeImpl extends AttributeImpl implements MapAttribute
|
|||||||
throw new AlfrescoRuntimeException("Unknown Attribute Type: " + value.getType());
|
throw new AlfrescoRuntimeException("Unknown Attribute Type: " + value.getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MapEntry mapEntry = new MapEntryImpl(this, entry.getKey(), newAttr);
|
MapEntryKey key = new MapEntryKey(this, entry.getKey());
|
||||||
|
MapEntry mapEntry = new MapEntryImpl(key, newAttr);
|
||||||
AVMDAOs.Instance().fMapEntryDAO.save(mapEntry);
|
AVMDAOs.Instance().fMapEntryDAO.save(mapEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -152,7 +153,7 @@ public class MapAttributeImpl extends AttributeImpl implements MapAttribute
|
|||||||
Map<String, Attribute> map = new HashMap<String, Attribute>();
|
Map<String, Attribute> map = new HashMap<String, Attribute>();
|
||||||
for (MapEntry entry : entries)
|
for (MapEntry entry : entries)
|
||||||
{
|
{
|
||||||
map.put(entry.getKey(), entry.getAttribute());
|
map.put(entry.getKey().getKey(), entry.getAttribute());
|
||||||
}
|
}
|
||||||
return map.entrySet();
|
return map.entrySet();
|
||||||
}
|
}
|
||||||
@@ -163,7 +164,8 @@ public class MapAttributeImpl extends AttributeImpl implements MapAttribute
|
|||||||
@Override
|
@Override
|
||||||
public Attribute get(String key)
|
public Attribute get(String key)
|
||||||
{
|
{
|
||||||
MapEntry entry = AVMDAOs.Instance().fMapEntryDAO.get(this, key);
|
MapEntryKey entryKey = new MapEntryKey(this, key);
|
||||||
|
MapEntry entry = AVMDAOs.Instance().fMapEntryDAO.get(entryKey);
|
||||||
if (entry == null)
|
if (entry == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
@@ -181,7 +183,7 @@ public class MapAttributeImpl extends AttributeImpl implements MapAttribute
|
|||||||
Set<String> keys = new HashSet<String>();
|
Set<String> keys = new HashSet<String>();
|
||||||
for (MapEntry entry : entries)
|
for (MapEntry entry : entries)
|
||||||
{
|
{
|
||||||
keys.add(entry.getKey());
|
keys.add(entry.getKey().getKey());
|
||||||
}
|
}
|
||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
@@ -192,7 +194,8 @@ public class MapAttributeImpl extends AttributeImpl implements MapAttribute
|
|||||||
@Override
|
@Override
|
||||||
public void put(String key, Attribute value)
|
public void put(String key, Attribute value)
|
||||||
{
|
{
|
||||||
MapEntry entry = AVMDAOs.Instance().fMapEntryDAO.get(this, key);
|
MapEntryKey entryKey = new MapEntryKey(this, key);
|
||||||
|
MapEntry entry = AVMDAOs.Instance().fMapEntryDAO.get(entryKey);
|
||||||
if (entry != null)
|
if (entry != null)
|
||||||
{
|
{
|
||||||
Attribute oldAttr = entry.getAttribute();
|
Attribute oldAttr = entry.getAttribute();
|
||||||
@@ -200,7 +203,7 @@ public class MapAttributeImpl extends AttributeImpl implements MapAttribute
|
|||||||
AVMDAOs.Instance().fAttributeDAO.delete(oldAttr);
|
AVMDAOs.Instance().fAttributeDAO.delete(oldAttr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
entry = new MapEntryImpl(this, key, value);
|
entry = new MapEntryImpl(entryKey, value);
|
||||||
AVMDAOs.Instance().fMapEntryDAO.save(entry);
|
AVMDAOs.Instance().fMapEntryDAO.save(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,7 +213,8 @@ public class MapAttributeImpl extends AttributeImpl implements MapAttribute
|
|||||||
@Override
|
@Override
|
||||||
public void remove(String key)
|
public void remove(String key)
|
||||||
{
|
{
|
||||||
MapEntry entry = AVMDAOs.Instance().fMapEntryDAO.get(this, key);
|
MapEntryKey entryKey = new MapEntryKey(this, key);
|
||||||
|
MapEntry entry = AVMDAOs.Instance().fMapEntryDAO.get(entryKey);
|
||||||
if (entry == null)
|
if (entry == null)
|
||||||
{
|
{
|
||||||
throw new AVMNotFoundException("Attribute Not Found: " + key);
|
throw new AVMNotFoundException("Attribute Not Found: " + key);
|
||||||
|
@@ -35,19 +35,7 @@ public interface MapEntry
|
|||||||
* Get the primary key.
|
* Get the primary key.
|
||||||
* @return The key.
|
* @return The key.
|
||||||
*/
|
*/
|
||||||
public long getId();
|
public MapEntryKey getKey();
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the map attribute that this entry belongs to.
|
|
||||||
* @return The map attribute.
|
|
||||||
*/
|
|
||||||
public MapAttribute getMap();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the lookup key for this entry.
|
|
||||||
* @return The key.
|
|
||||||
*/
|
|
||||||
public String getKey();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the value attribute.
|
* Get the value attribute.
|
||||||
|
@@ -28,11 +28,10 @@ public interface MapEntryDAO
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an entry by name.
|
* Get an entry by name.
|
||||||
* @param mapAttr The map to get the entry from.
|
|
||||||
* @param key The key of the entry.
|
* @param key The key of the entry.
|
||||||
* @return A MapEntry or null.
|
* @return A MapEntry or null.
|
||||||
*/
|
*/
|
||||||
public MapEntry get(MapAttribute mapAttr, String key);
|
public MapEntry get(MapEntryKey key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve all the entries in a map.
|
* Retrieve all the entries in a map.
|
||||||
|
@@ -31,11 +31,7 @@ package org.alfresco.repo.attributes;
|
|||||||
*/
|
*/
|
||||||
public class MapEntryImpl implements MapEntry
|
public class MapEntryImpl implements MapEntry
|
||||||
{
|
{
|
||||||
private long fID;
|
private MapEntryKey fKey;
|
||||||
|
|
||||||
private MapAttribute fMap;
|
|
||||||
|
|
||||||
private String fKey;
|
|
||||||
|
|
||||||
private Attribute fAttribute;
|
private Attribute fAttribute;
|
||||||
|
|
||||||
@@ -43,11 +39,9 @@ public class MapEntryImpl implements MapEntry
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapEntryImpl(MapAttribute map,
|
public MapEntryImpl(MapEntryKey key,
|
||||||
String key,
|
|
||||||
Attribute attribute)
|
Attribute attribute)
|
||||||
{
|
{
|
||||||
fMap = map;
|
|
||||||
fKey = key;
|
fKey = key;
|
||||||
fAttribute = attribute;
|
fAttribute = attribute;
|
||||||
}
|
}
|
||||||
@@ -69,26 +63,10 @@ public class MapEntryImpl implements MapEntry
|
|||||||
fAttribute = attr;
|
fAttribute = attr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.MapEntry#getId()
|
|
||||||
*/
|
|
||||||
public long getId()
|
|
||||||
{
|
|
||||||
return fID;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Setter.
|
|
||||||
*/
|
|
||||||
public void setId(long id)
|
|
||||||
{
|
|
||||||
fID = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.repo.attributes.MapEntry#getKey()
|
* @see org.alfresco.repo.attributes.MapEntry#getKey()
|
||||||
*/
|
*/
|
||||||
public String getKey()
|
public MapEntryKey getKey()
|
||||||
{
|
{
|
||||||
return fKey;
|
return fKey;
|
||||||
}
|
}
|
||||||
@@ -96,24 +74,8 @@ public class MapEntryImpl implements MapEntry
|
|||||||
/**
|
/**
|
||||||
* Setter.
|
* Setter.
|
||||||
*/
|
*/
|
||||||
public void setKey(String key)
|
public void setKey(MapEntryKey key)
|
||||||
{
|
{
|
||||||
fKey = key;
|
fKey = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.attributes.MapEntry#getMap()
|
|
||||||
*/
|
|
||||||
public MapAttribute getMap()
|
|
||||||
{
|
|
||||||
return fMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Setter.
|
|
||||||
*/
|
|
||||||
public void setMap(MapAttribute map)
|
|
||||||
{
|
|
||||||
fMap = map;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
83
source/java/org/alfresco/repo/attributes/MapEntryKey.java
Normal file
83
source/java/org/alfresco/repo/attributes/MapEntryKey.java
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
* As a special exception to the terms and conditions of version 2.0 of
|
||||||
|
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||||
|
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||||
|
* FLOSS exception. You should have recieved a copy of the text describing
|
||||||
|
* the FLOSS exception, and it is also available here:
|
||||||
|
* http://www.alfresco.com/legal/licensing
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.alfresco.repo.attributes;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Key class for MapEntries.
|
||||||
|
* @author britt
|
||||||
|
*/
|
||||||
|
public class MapEntryKey implements Serializable
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1637682889407656800L;
|
||||||
|
|
||||||
|
private MapAttribute fMap;
|
||||||
|
|
||||||
|
private String fKey;
|
||||||
|
|
||||||
|
public MapEntryKey()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapEntryKey(MapAttribute map, String key)
|
||||||
|
{
|
||||||
|
fMap = map;
|
||||||
|
fKey = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the Key
|
||||||
|
*/
|
||||||
|
public String getKey()
|
||||||
|
{
|
||||||
|
return fKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param key the Key to set
|
||||||
|
*/
|
||||||
|
public void setKey(String key)
|
||||||
|
{
|
||||||
|
fKey = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the Map
|
||||||
|
*/
|
||||||
|
public MapAttribute getMap()
|
||||||
|
{
|
||||||
|
return fMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param map the Map to set
|
||||||
|
*/
|
||||||
|
public void setMap(MapAttribute map)
|
||||||
|
{
|
||||||
|
fMap = map;
|
||||||
|
}
|
||||||
|
}
|
@@ -109,7 +109,7 @@ public class AttributeDAOHibernate extends HibernateDaoSupport implements
|
|||||||
{
|
{
|
||||||
AttrQueryHelper helper = new AttrQueryHelperImpl();
|
AttrQueryHelper helper = new AttrQueryHelperImpl();
|
||||||
String predicate = query.getPredicate(helper);
|
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);
|
Query hQuery = getSession().createQuery(fullQuery);
|
||||||
hQuery.setEntity("map", map);
|
hQuery.setEntity("map", map);
|
||||||
for (Map.Entry<String, String> param : helper.getParameters().entrySet())
|
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>>();
|
List<Pair<String, Attribute>> result = new ArrayList<Pair<String, Attribute>>();
|
||||||
for (MapEntry entry : hits)
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
<class table="alf_attributes" abstract="true"
|
<class table="alf_attributes" abstract="true"
|
||||||
name="AttributeImpl" proxy="Attribute"
|
name="AttributeImpl" proxy="Attribute"
|
||||||
optimistic-lock="version"
|
optimistic-lock="version"
|
||||||
lazy="true">
|
lazy="false">
|
||||||
<cache usage="read-write"/>
|
<cache usage="read-write"/>
|
||||||
<id name="id" column="id" type="long">
|
<id name="id" column="id" type="long">
|
||||||
<generator class="native"/>
|
<generator class="native"/>
|
||||||
@@ -17,76 +17,73 @@
|
|||||||
<many-to-one name="acl" column="acl_id" foreign-key="fk_attributes_n_acl"
|
<many-to-one name="acl" column="acl_id" foreign-key="fk_attributes_n_acl"
|
||||||
class="org.alfresco.repo.domain.hibernate.DbAccessControlListImpl"/>
|
class="org.alfresco.repo.domain.hibernate.DbAccessControlListImpl"/>
|
||||||
<!-- A boolean valued attribute -->
|
<!-- A boolean valued attribute -->
|
||||||
<subclass name="BooleanAttributeImpl" proxy="BooleanAttribute" lazy="true"
|
<subclass name="BooleanAttributeImpl" proxy="BooleanAttribute" lazy="false"
|
||||||
discriminator-value="O">
|
discriminator-value="O">
|
||||||
<property name="booleanValue" column="bool_value" type="boolean"/>
|
<property name="booleanValue" column="bool_value" type="boolean"/>
|
||||||
</subclass>
|
</subclass>
|
||||||
<!-- A byte valued attribute -->
|
<!-- A byte valued attribute -->
|
||||||
<subclass name="ByteAttributeImpl" proxy="ByteAttribute" lazy="true"
|
<subclass name="ByteAttributeImpl" proxy="ByteAttribute" lazy="false"
|
||||||
discriminator-value="Y">
|
discriminator-value="Y">
|
||||||
<property name="byteValue" column="byte_value" type="byte"/>
|
<property name="byteValue" column="byte_value" type="byte"/>
|
||||||
</subclass>
|
</subclass>
|
||||||
<!-- A short valued attribute -->
|
<!-- A short valued attribute -->
|
||||||
<subclass name="ShortAttributeImpl" proxy="ShortAttribute" lazy="true"
|
<subclass name="ShortAttributeImpl" proxy="ShortAttribute" lazy="false"
|
||||||
discriminator-value="H">
|
discriminator-value="H">
|
||||||
<property name="shortValue" column="short_value" type="short"/>
|
<property name="shortValue" column="short_value" type="short"/>
|
||||||
</subclass>
|
</subclass>
|
||||||
<!-- An integer valued attribute. -->
|
<!-- An integer valued attribute. -->
|
||||||
<subclass name="IntAttributeImpl" proxy="IntAttribute" lazy="true"
|
<subclass name="IntAttributeImpl" proxy="IntAttribute" lazy="false"
|
||||||
discriminator-value="I">
|
discriminator-value="I">
|
||||||
<property name="intValue" column="int_value" type="int"/>
|
<property name="intValue" column="int_value" type="int"/>
|
||||||
</subclass>
|
</subclass>
|
||||||
<!-- A long valued attribute -->
|
<!-- A long valued attribute -->
|
||||||
<subclass name="LongAttributeImpl" proxy="LongAttribute" lazy="true"
|
<subclass name="LongAttributeImpl" proxy="LongAttribute" lazy="false"
|
||||||
discriminator-value="L">
|
discriminator-value="L">
|
||||||
<property name="longValue" column="long_value" type="long"/>
|
<property name="longValue" column="long_value" type="long"/>
|
||||||
</subclass>
|
</subclass>
|
||||||
<!-- A float valued attribute -->
|
<!-- A float valued attribute -->
|
||||||
<subclass name="FloatAttributeImpl" proxy="FloatAttribute" lazy="true"
|
<subclass name="FloatAttributeImpl" proxy="FloatAttribute" lazy="false"
|
||||||
discriminator-value="F">
|
discriminator-value="F">
|
||||||
<property name="floatValue" column="float_value" type="float"/>
|
<property name="floatValue" column="float_value" type="float"/>
|
||||||
</subclass>
|
</subclass>
|
||||||
<!-- A double valued attribute -->
|
<!-- A double valued attribute -->
|
||||||
<subclass name="DoubleAttributeImpl" proxy="DoubleAttribute" lazy="true"
|
<subclass name="DoubleAttributeImpl" proxy="DoubleAttribute" lazy="false"
|
||||||
discriminator-value="D">
|
discriminator-value="D">
|
||||||
<property name="doubleValue" column="double_value" type="double"/>
|
<property name="doubleValue" column="double_value" type="double"/>
|
||||||
</subclass>
|
</subclass>
|
||||||
<!-- A string valued attribute -->
|
<!-- A string valued attribute -->
|
||||||
<subclass name="StringAttributeImpl" proxy="StringAttribute" lazy="true"
|
<subclass name="StringAttributeImpl" proxy="StringAttribute" lazy="false"
|
||||||
discriminator-value="S">
|
discriminator-value="S">
|
||||||
<property name="stringValue" column="string_value" type="string"
|
<property name="stringValue" column="string_value" type="string"
|
||||||
length="512"/>
|
length="512"/>
|
||||||
</subclass>
|
</subclass>
|
||||||
<!-- A serializable attribute -->
|
<!-- A serializable attribute -->
|
||||||
<subclass name="SerializableAttributeImpl" proxy="SerializableAttribute" lazy="true"
|
<subclass name="SerializableAttributeImpl" proxy="SerializableAttribute" lazy="false"
|
||||||
discriminator-value="E">
|
discriminator-value="E">
|
||||||
<property name="serializableValue" column="serializable_value" lazy="true"
|
<property name="serializableValue" column="serializable_value" lazy="false"
|
||||||
length="8192"/>
|
length="8192"/>
|
||||||
</subclass>
|
</subclass>
|
||||||
<!-- A map attribute -->
|
<!-- A map attribute -->
|
||||||
<subclass name="MapAttributeImpl" proxy="MapAttribute" lazy="true"
|
<subclass name="MapAttributeImpl" proxy="MapAttribute" lazy="false"
|
||||||
discriminator-value="M">
|
discriminator-value="M">
|
||||||
</subclass>
|
</subclass>
|
||||||
<!-- A List class -->
|
<!-- A List class -->
|
||||||
<subclass name="ListAttributeImpl" proxy="ListAttribute" lazy="true"
|
<subclass name="ListAttributeImpl" proxy="ListAttribute" lazy="false"
|
||||||
discriminator-value="T">
|
discriminator-value="T">
|
||||||
</subclass>
|
</subclass>
|
||||||
</class>
|
</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"/>
|
<cache usage="read-write"/>
|
||||||
<id name="name" type="string" length="160"/>
|
<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>
|
||||||
<class name="MapEntryImpl" proxy="MapEntry" lazy="false" table="alf_map_attribute_entries">
|
<class name="MapEntryImpl" proxy="MapEntry" lazy="false" table="alf_map_attribute_entries">
|
||||||
<cache usage="read-write"/>
|
<cache usage="read-write"/>
|
||||||
<id name="id" column="id" type="long">
|
<composite-id name="key" class="MapEntryKey">
|
||||||
<generator class="native"/>
|
<key-many-to-one class="MapAttributeImpl" name="map" column="map_id"/>
|
||||||
</id>
|
<key-property name="key" type="string" length="160" column="mkey"/>
|
||||||
<natural-id>
|
</composite-id>
|
||||||
<many-to-one class="MapAttributeImpl" name="map" column="map_id"/>
|
<many-to-one class="AttributeImpl" name="attribute" column="attribute_id" lazy="false"/>
|
||||||
<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"/>
|
|
||||||
</class>
|
</class>
|
||||||
<class name="ListEntryImpl" proxy="ListEntry" lazy="false" table="alf_list_attribute_entries">
|
<class name="ListEntryImpl" proxy="ListEntry" lazy="false" table="alf_list_attribute_entries">
|
||||||
<cache usage="read-write"/>
|
<cache usage="read-write"/>
|
||||||
@@ -94,6 +91,6 @@
|
|||||||
<key-many-to-one class="ListAttributeImpl" name="list" column="list_id"/>
|
<key-many-to-one class="ListAttributeImpl" name="list" column="list_id"/>
|
||||||
<key-property name="index" type="int" column="mindex"/>
|
<key-property name="index" type="int" column="mindex"/>
|
||||||
</composite-id>
|
</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>
|
</class>
|
||||||
</hibernate-mapping>
|
</hibernate-mapping>
|
||||||
|
@@ -30,6 +30,8 @@ import java.util.List;
|
|||||||
import org.alfresco.repo.attributes.MapAttribute;
|
import org.alfresco.repo.attributes.MapAttribute;
|
||||||
import org.alfresco.repo.attributes.MapEntry;
|
import org.alfresco.repo.attributes.MapEntry;
|
||||||
import org.alfresco.repo.attributes.MapEntryDAO;
|
import org.alfresco.repo.attributes.MapEntryDAO;
|
||||||
|
import org.alfresco.repo.attributes.MapEntryImpl;
|
||||||
|
import org.alfresco.repo.attributes.MapEntryKey;
|
||||||
import org.hibernate.Query;
|
import org.hibernate.Query;
|
||||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||||
|
|
||||||
@@ -53,7 +55,7 @@ public class MapEntryDAOHibernate extends HibernateDaoSupport implements
|
|||||||
*/
|
*/
|
||||||
public void delete(MapAttribute mapAttr)
|
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.setEntity("map", mapAttr);
|
||||||
query.executeUpdate();
|
query.executeUpdate();
|
||||||
}
|
}
|
||||||
@@ -61,12 +63,9 @@ public class MapEntryDAOHibernate extends HibernateDaoSupport implements
|
|||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.repo.attributes.MapEntryDAO#get(org.alfresco.repo.attributes.MapAttribute, java.lang.String)
|
* @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");
|
return (MapEntry)getSession().get(MapEntryImpl.class, key);
|
||||||
query.setEntity("map", mapAttr);
|
|
||||||
query.setParameter("key", key);
|
|
||||||
return (MapEntry)query.uniqueResult();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -75,7 +74,7 @@ public class MapEntryDAOHibernate extends HibernateDaoSupport implements
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public List<MapEntry> get(MapAttribute mapAttr)
|
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);
|
query.setEntity("map", mapAttr);
|
||||||
return (List<MapEntry>)query.list();
|
return (List<MapEntry>)query.list();
|
||||||
}
|
}
|
||||||
@@ -93,7 +92,7 @@ public class MapEntryDAOHibernate extends HibernateDaoSupport implements
|
|||||||
*/
|
*/
|
||||||
public int size(MapAttribute mapAttr)
|
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);
|
query.setEntity("map", mapAttr);
|
||||||
return ((Long)query.uniqueResult()).intValue();
|
return ((Long)query.uniqueResult()).intValue();
|
||||||
}
|
}
|
||||||
|
@@ -46,6 +46,6 @@ public class AttrQueryEquals extends AttrQuery
|
|||||||
{
|
{
|
||||||
String name = "name" + helper.getNextSuffix();
|
String name = "name" + helper.getNextSuffix();
|
||||||
helper.setParameter(name, fValue);
|
helper.setParameter(name, fValue);
|
||||||
return "me.key = :" + name;
|
return "me.key.key = :" + name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -49,6 +49,6 @@ public class AttrQueryGT extends AttrQuery
|
|||||||
{
|
{
|
||||||
String name = "name" + helper.getNextSuffix();
|
String name = "name" + helper.getNextSuffix();
|
||||||
helper.setParameter(name, fValue);
|
helper.setParameter(name, fValue);
|
||||||
return "me.key > :" + name;
|
return "me.key.key > :" + name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -50,6 +50,6 @@ public class AttrQueryGTE extends AttrQuery
|
|||||||
{
|
{
|
||||||
String name = "name" + helper.getNextSuffix();
|
String name = "name" + helper.getNextSuffix();
|
||||||
helper.setParameter(name, fValue);
|
helper.setParameter(name, fValue);
|
||||||
return "me.key >= :" + name;
|
return "me.key.key >= :" + name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -49,6 +49,6 @@ public class AttrQueryLT extends AttrQuery
|
|||||||
{
|
{
|
||||||
String name = "name" + helper.getNextSuffix();
|
String name = "name" + helper.getNextSuffix();
|
||||||
helper.setParameter(name, fValue);
|
helper.setParameter(name, fValue);
|
||||||
return "me.key < :" + name;
|
return "me.key.key < :" + name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -49,6 +49,6 @@ public class AttrQueryLTE extends AttrQuery
|
|||||||
{
|
{
|
||||||
String name = "name" + helper.getNextSuffix();
|
String name = "name" + helper.getNextSuffix();
|
||||||
helper.setParameter(name, fValue);
|
helper.setParameter(name, fValue);
|
||||||
return "me.key <= :" + name;
|
return "me.key.key <= :" + name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -50,6 +50,6 @@ public class AttrQueryLike extends AttrQuery
|
|||||||
{
|
{
|
||||||
String name = "name" + helper.getNextSuffix();
|
String name = "name" + helper.getNextSuffix();
|
||||||
helper.setParameter(name, fValue);
|
helper.setParameter(name, fValue);
|
||||||
return "me.key like :" + name;
|
return "me.key.key like :" + name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -49,6 +49,6 @@ public class AttrQueryNE extends AttrQuery
|
|||||||
{
|
{
|
||||||
String name = "name" + helper.getNextSuffix();
|
String name = "name" + helper.getNextSuffix();
|
||||||
helper.setParameter(name, fValue);
|
helper.setParameter(name, fValue);
|
||||||
return "me.key <> :" + name;
|
return "me.key.key <> :" + name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user