ListAttribute seems to be mostly working, though I had to tweak hibernate-cfg.properties to

make it suck back generated primary keys.
Restructured ListEntry so that most most gets are via Session.get() rather than by query.
Added new methods to AttributeService to handle ListAttribute specific operations.
Added a little more testing for AttributeService.
I'm praying that the build will be repaired, since my efforts having been doing
so much lately.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5553 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2007-04-26 00:31:33 +00:00
parent 602440a983
commit d3aae2a9b7
18 changed files with 404 additions and 164 deletions

View File

@@ -90,13 +90,10 @@
</class>
<class name="ListEntryImpl" proxy="ListEntry" lazy="false" table="alf_list_attribute_entries">
<cache usage="read-write"/>
<id name="id" column="id" type="long">
<generator class="native"/>
</id>
<natural-id>
<many-to-one class="ListAttributeImpl" name="list" column="list_id"/>
<property name="index" type="int" column="mindex" index="list_index_index"/>
</natural-id>
<composite-id name="key" class="ListEntryKey">
<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"/>
</class>
</hibernate-mapping>

View File

@@ -30,6 +30,8 @@ import java.util.List;
import org.alfresco.repo.attributes.ListAttribute;
import org.alfresco.repo.attributes.ListEntry;
import org.alfresco.repo.attributes.ListEntryDAO;
import org.alfresco.repo.attributes.ListEntryImpl;
import org.alfresco.repo.attributes.ListEntryKey;
import org.hibernate.Query;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
@@ -53,7 +55,7 @@ public class ListEntryDAOHibernate extends HibernateDaoSupport implements
*/
public void delete(ListAttribute list)
{
Query query = getSession().createQuery("delete from ListEntryImpl le where le.list = :list");
Query query = getSession().createQuery("delete from ListEntryImpl le where le.key.list = :list");
query.setEntity("list", list);
query.executeUpdate();
}
@@ -61,12 +63,9 @@ public class ListEntryDAOHibernate extends HibernateDaoSupport implements
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.ListEntryDAO#get(org.alfresco.repo.attributes.ListAttribute, int)
*/
public ListEntry get(ListAttribute list, int index)
public ListEntry get(ListEntryKey key)
{
Query query = getSession().createQuery("from ListEntryImpl le where le.list = :list and le.index = :index");
query.setEntity("list", list);
query.setInteger("index", index);
return (ListEntry)query.uniqueResult();
return (ListEntry)getSession().get(ListEntryImpl.class, key);
}
/* (non-Javadoc)
@@ -75,7 +74,7 @@ public class ListEntryDAOHibernate extends HibernateDaoSupport implements
@SuppressWarnings("unchecked")
public List<ListEntry> get(ListAttribute list)
{
Query query = getSession().createQuery("from ListEntryImpl le where le.list = :list");
Query query = getSession().createQuery("from ListEntryImpl le where le.key.list = :list");
query.setEntity("list", list);
return (List<ListEntry>)query.list();
}
@@ -93,8 +92,8 @@ public class ListEntryDAOHibernate extends HibernateDaoSupport implements
*/
public int size(ListAttribute list)
{
Query query = getSession().createQuery("select count() from ListEntryImpl le where le.list = :list");
Query query = getSession().createQuery("select count(*) from ListEntryImpl le where le.key.list = :list");
query.setEntity("list", list);
return (Integer)query.uniqueResult();
return ((Long)query.uniqueResult()).intValue();
}
}

View File

@@ -93,8 +93,8 @@ public class MapEntryDAOHibernate extends HibernateDaoSupport implements
*/
public int size(MapAttribute mapAttr)
{
Query query = getSession().createQuery("select count() from MapEntryImpl me where me.map = :map");
Query query = getSession().createQuery("select count(me) from MapEntryImpl me where me.map = :map");
query.setEntity("map", mapAttr);
return (Integer)query.uniqueResult();
return ((Long)query.uniqueResult()).intValue();
}
}