From 45d25dcd7ed2980ca94feec6bd201676286bab1e Mon Sep 17 00:00:00 2001 From: Jan Vonka Date: Thu, 17 Sep 2009 17:14:00 +0000 Subject: [PATCH] iBatis boolean parameterization in AVM select queries (follow-on for r16347) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@16353 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../avm-common-SqlMap.xml | 29 +++++++++++++++++-- .../avm-insert-SqlMap.xml | 22 -------------- .../domain/avm/ibatis/AVMNodeDAOImpl.java | 16 +++++++--- 3 files changed, 39 insertions(+), 28 deletions(-) diff --git a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/avm-common-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/avm-common-SqlMap.xml index 35f7fa9e15..4bac3e5b14 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/avm-common-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/avm-common-SqlMap.xml @@ -137,6 +137,10 @@ + + + + @@ -419,7 +423,17 @@ (class_type = 'layereddirectory' or class_type = 'layeredfile') and store_new_id = ? - + + + + select + an.* + from + avm_child_entries ce + right outer join avm_nodes an on (an.id = ce.child_id) + where + ce.parent_id is null and + an.is_root = ? + + diff --git a/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/avm-insert-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/avm-insert-SqlMap.xml index bba62bf43d..d70a735bbd 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/avm-insert-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/avm-insert-SqlMap.xml @@ -34,26 +34,4 @@ - - - - \ No newline at end of file diff --git a/source/java/org/alfresco/repo/domain/avm/ibatis/AVMNodeDAOImpl.java b/source/java/org/alfresco/repo/domain/avm/ibatis/AVMNodeDAOImpl.java index 89208622ea..20efa87660 100644 --- a/source/java/org/alfresco/repo/domain/avm/ibatis/AVMNodeDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/avm/ibatis/AVMNodeDAOImpl.java @@ -59,8 +59,8 @@ public class AVMNodeDAOImpl extends AbstractAVMNodeDAOImpl private static final String SELECT_AVM_NODES_NEW_LAYERED_IN_STORE = "alfresco.avm.select_AVMNodes_newLayeredInStore"; private static final String SELECT_AVM_NODE_IDS_NEW_LAYERED_IN_STORE = "alfresco.avm.select_AVMNodes_IDs_newLayeredInStore"; private static final String UPDATE_AVM_NODES_CLEAR_NEW_IN_STORE = "alfresco.avm.update_AVMNodes_clearNewInStore"; - private static final String SELECT_AVM_NODES_ORPHANS = "alfresco.avm.select_AVMNodes_orphans"; - private static final String SELECT_AVM_NODES_LAYERED_DIRECTORIES = "alfresco.avm.select_AVMNodes_layeredDirectories"; + private static final String SELECT_AVM_NODES_NULL_PARENT_AND_ISROOT_TF= "alfresco.avm.select_AVMNodes_nullParentAndIsRootTF"; + private static final String SELECT_AVM_NODES_LAYERED_DIRECTORIES_AND_PRIMARY_TF = "alfresco.avm.select_AVMNodes_layeredDirectoriesAndPrimaryTF"; private static final String SELECT_AVM_NODES_LAYERED_FILES = "alfresco.avm.select_AVMNodes_layeredFiles"; private static final String SELECT_AVM_NODE_IDS_BY_ACL_ID = "alfresco.avm.select_AVMNodes_IDs_byAcl"; @@ -168,14 +168,22 @@ public class AVMNodeDAOImpl extends AbstractAVMNodeDAOImpl @Override protected List getNodeEntityOrphans(int maxSize) { - return (List) template.queryForList(SELECT_AVM_NODES_ORPHANS, 0, maxSize); + Map params = new HashMap(1); + params.put("bool", false); + + // all nodes with null parent and not a root + return (List) template.queryForList(SELECT_AVM_NODES_NULL_PARENT_AND_ISROOT_TF, params, 0, maxSize); } @SuppressWarnings("unchecked") @Override protected List getAllLayeredDirectoryNodeEntities() { - return (List) template.queryForList(SELECT_AVM_NODES_LAYERED_DIRECTORIES); + Map params = new HashMap(1); + params.put("bool", true); + + // all primary layered directories + return (List) template.queryForList(SELECT_AVM_NODES_LAYERED_DIRECTORIES_AND_PRIMARY_TF, params); } @SuppressWarnings("unchecked")