diff --git a/config/alfresco/dao/dao-context.xml b/config/alfresco/dao/dao-context.xml index 935b972655..f467aeec21 100644 --- a/config/alfresco/dao/dao-context.xml +++ b/config/alfresco/dao/dao-context.xml @@ -20,10 +20,12 @@ + - + + @@ -42,24 +44,24 @@ - + - + - + - + @@ -79,27 +81,27 @@ - + - + - + - + - + @@ -109,7 +111,7 @@ - + @@ -126,7 +128,7 @@ - + @@ -135,14 +137,14 @@ - + - + @@ -150,18 +152,18 @@ - + - + - + @@ -226,7 +228,7 @@ - + @@ -243,18 +245,18 @@ - + - + - + diff --git a/config/alfresco/ibatis/alfresco-SqlMapConfig.xml b/config/alfresco/ibatis/alfresco-SqlMapConfig.xml index a6381530c3..7e399e482d 100644 --- a/config/alfresco/ibatis/alfresco-SqlMapConfig.xml +++ b/config/alfresco/ibatis/alfresco-SqlMapConfig.xml @@ -17,34 +17,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/config/alfresco/ibatis/ibatis-context.xml b/config/alfresco/ibatis/ibatis-context.xml index 548b35c3f4..d58d4948dc 100644 --- a/config/alfresco/ibatis/ibatis-context.xml +++ b/config/alfresco/ibatis/ibatis-context.xml @@ -19,7 +19,7 @@ - + javax.sql.DataSource @@ -31,7 +31,7 @@ - + @@ -40,7 +40,7 @@ getConnection - + @@ -56,35 +56,42 @@ - - - + + + - - classpath:alfresco/ibatis/alfresco-SqlMapConfig.xml - + classpath:alfresco/ibatis/repo-SqlMapConfig.xml + - - + + + - - + + + - - + + + - - + + + - - + + + - - + + + - - - + + + + + diff --git a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/appliedpatch-common-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/appliedpatch-common-SqlMap.xml index b1ca96f5e1..5e4d7d8f60 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/appliedpatch-common-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/appliedpatch-common-SqlMap.xml @@ -1,29 +1,23 @@ - + - + - - - - - + - + - - - - - + + + + + @@ -34,7 +28,8 @@ - + + insert into alf_applied_patch ( id, description, @@ -44,10 +39,10 @@ ) values ( - #id#, #description#, - #fixesFromSchema#, #fixesToSchema#, #targetSchema#, - #appliedToSchema#, #appliedOnDate#, #appliedToServer#, - #wasExecuted#, #succeeded#, #report# + #{id}, #{description,jdbcType=VARCHAR}, + #{fixesFromSchema,jdbcType=INTEGER}, #{fixesToSchema,jdbcType=INTEGER}, #{targetSchema,jdbcType=INTEGER}, + #{appliedToSchema,jdbcType=INTEGER}, #{appliedOnDate,jdbcType=DATE}, #{appliedToServer,jdbcType=VARCHAR}, + #{wasExecuted,jdbcType=BOOLEAN}, #{succeeded,jdbcType=BOOLEAN}, #{report,jdbcType=VARCHAR} ) @@ -55,28 +50,29 @@ - + + update alf_applied_patch set - description = #description#, - fixes_from_schema = #fixesFromSchema#, - fixes_to_schema = #fixesToSchema#, - target_schema = #targetSchema#, - applied_to_schema = #appliedToSchema#, - applied_on_date = #appliedOnDate#, - applied_to_server = #appliedToServer#, - was_executed = #wasExecuted#, - succeeded = #succeeded#, - report = #report# + description = #{description,jdbcType=VARCHAR}, + fixes_from_schema = #{fixesFromSchema,jdbcType=INTEGER}, + fixes_to_schema = #{fixesToSchema,jdbcType=INTEGER}, + target_schema = #{targetSchema,jdbcType=INTEGER}, + applied_to_schema = #{appliedToSchema,jdbcType=INTEGER}, + applied_on_date = #{appliedOnDate,jdbcType=DATE}, + applied_to_server = #{appliedToServer,jdbcType=VARCHAR}, + was_executed = #{wasExecuted,jdbcType=BOOLEAN}, + succeeded = #{succeeded,jdbcType=BOOLEAN}, + report = #{report,jdbcType=VARCHAR} where - id = #id# + id = #{id} - select id, description, fixes_from_schema, fixes_to_schema, target_schema, @@ -85,7 +81,7 @@ from alf_applied_patch where - id = #id# + id = #{id} - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/audit-common-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/audit-common-SqlMap.xml index cded15631a..a03fabcb69 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/audit-common-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/audit-common-SqlMap.xml @@ -1,46 +1,33 @@ - + - - - - - - - - - - - - + - + - + - + - + @@ -49,15 +36,15 @@ - + type="AuditQueryResult"> + - + @@ -67,17 +54,32 @@ insert into alf_audit_model (content_data_id, content_crc) - values (#contentDataId#, #contentCrc#) + values (#{contentDataId}, #{contentCrc}) + + + + insert into alf_audit_model (id, content_data_id, content_crc) + values (#{id}, #{contentDataId}, #{contentCrc}) insert into alf_audit_app (version, app_name_id, audit_model_id, disabled_paths_id) - values (#version#, #applicationNameId#, #auditModelId#, #disabledPathsId#) + values (#{version}, #{applicationNameId}, #{auditModelId}, #{disabledPathsId}) + + + + insert into alf_audit_app (id, version, app_name_id, audit_model_id, disabled_paths_id) + values (#{id}, #{version}, #{applicationNameId}, #{auditModelId}, #{disabledPathsId}) insert into alf_audit_entry (audit_app_id, audit_user_id, audit_time, audit_values_id) - values (#auditApplicationId#, #auditUserId#, #auditTime#, #auditValuesId#) + values (#{auditApplicationId}, #{auditUserId}, #{auditTime}, #{auditValuesId}) + + + + insert into alf_audit_entry (id, audit_app_id, audit_user_id, audit_time, audit_values_id) + values (#{id}, #{auditApplicationId}, #{auditUserId}, #{auditTime}, #{auditValuesId}) @@ -85,13 +87,13 @@ - select * from alf_audit_model where - content_crc = #contentCrc# + content_crc = #{contentCrc} @@ -115,83 +117,90 @@ - + update alf_audit_app set - version = #version#, - app_name_id = #applicationNameId#, - audit_model_id = #auditModelId#, - disabled_paths_id = #disabledPathsId# + version = #{version}, + app_name_id = #{applicationNameId}, + audit_model_id = #{auditModelId}, + disabled_paths_id = #{disabledPathsId} where - id = #id# - - and version = (#version#-1) - + id = #{id} + + and version = (#{version} - 1) + - + delete from alf_audit_entry - - - audit_app_id = #auditApplicationId# - - - = #auditFromTime#]]> - - - - - - id in #auditEntryIds[]# - - + + + audit_app_id = #{auditApplicationId} + + + and audit_app_id = #{auditApplicationId} + + + = #{auditFromTime}]]> + + + + + + and id in + + #{item} + + + - - - app.app_name_id = #auditAppNameId# - - - entry.audit_user_id = #auditUserId# - - - = #auditFromId#]]> - - - - - - = #auditFromTime#]]> - - - - - - sp_pl.key_prop_id = #searchKeyId# - - - sp_pl.value_prop_id = #searchValueId# - - + + + app.app_name_id = #{auditAppNameId} + + + and entry.audit_user_id = #{auditUserId} + + + = #{auditFromId}]]> + + + + + + = #{auditFromTime}]]> + + + + + + and sp_pl.key_prop_id = #{searchKeyId} + + + and sp_pl.value_prop_id = #{searchValueId} + + + - + order by entry.id asc - - + + order by entry.id desc - + - select app.app_name_id as audit_app_name_id, entry.id as audit_entry_id, @@ -214,9 +223,9 @@ alf_audit_app app join alf_audit_entry entry on (entry.audit_app_id = app.id) - + join alf_prop_link sp_pl on (sp_pl.root_prop_id = entry.audit_values_id) - + join alf_prop_link pl on (pl.root_prop_id = entry.audit_values_id) join alf_prop_value pv on (pl.value_prop_id = pv.id) @@ -228,7 +237,7 @@ - select app.app_name_id as audit_app_name_id, entry.id as audit_entry_id, @@ -239,12 +248,12 @@ alf_audit_app app join alf_audit_entry entry on (entry.audit_app_id = app.id) - + join alf_prop_link sp_pl on (sp_pl.root_prop_id = entry.audit_values_id) - + - \ No newline at end of file + \ No newline at end of file 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 ac5f4ff089..ae80efa586 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 @@ -1,34 +1,16 @@ - + - - - - - - - - - - - - - - - - - - + + - + @@ -37,22 +19,22 @@ - + - - + + - + - + @@ -67,9 +49,9 @@ - - - + + + @@ -79,54 +61,54 @@ - + - - + + - + - + - + - + - + - - + + - + - + - + - + @@ -135,49 +117,49 @@ - + - + - + - + - + - + - + - + - - - + + + @@ -189,9 +171,9 @@ - - - + + + @@ -203,10 +185,10 @@ - + - - + + @@ -218,7 +200,7 @@ - + @@ -233,32 +215,32 @@ insert into avm_stores (next_version_id, name, vers, current_root_id, acl_id) - values (#version#, #name#, 0, null, null) + values (#{version}, #{name}, 0, null, null) insert into avm_stores (id, next_version_id, name, vers, current_root_id, acl_id) - values (#id#, #version#, #name#, 0, null, null) + values (#{id}, #{version}, #{name}, 0, null, null) insert into avm_nodes (class_type, deletedType, version_id, vers, store_new_id, acl_id, guid, owner, creator, createDate, lastModifier, modDate, accessDate, is_root, layer_id, indirection, indirection_version, primary_indirection, opacity, content_url, mime_type, encoding, length) - values (#classType#, #deletedType#, #version#, 0, #storeNewId#, #aclId#, #guid#, #owner#, #creator#, #createdDate#, #modifier#, #modifiedDate#, #accessDate#, #isRoot#, #layerId#, #indirection#, #indirectionVersion#, #primaryIndirection#, #opacity#, #contentUrl#, #mimetype#, #encoding#, #length#) + values (#{classType}, #{deletedType}, #{version}, 0, #{storeNewId}, #{aclId}, #{guid}, #{owner}, #{creator}, #{createdDate}, #{modifier}, #{modifiedDate}, #{accessDate}, #{isRoot}, #{layerId}, #{indirection}, #{indirectionVersion}, #{primaryIndirection}, #{opacity}, #{contentUrl}, #{mimetype}, #{encoding}, #{length}) insert into avm_nodes (id, class_type, deletedType, version_id, vers, store_new_id, acl_id, guid, owner, creator, createDate, lastModifier, modDate, accessDate, is_root, layer_id, indirection, indirection_version, primary_indirection, opacity, content_url, mime_type, encoding, length) - values (#id#, #classType#, #deletedType#, #version#, 0, #storeNewId#, #aclId#, #guid#, #owner#, #creator#, #createdDate#, #modifier#, #modifiedDate#, #accessDate#, #isRoot#, #layerId#, #indirection#, #indirectionVersion#, #primaryIndirection#, #opacity#, #contentUrl#, #mimetype#, #encoding#, #length#) + values (#{id}, #{classType}, #{deletedType}, #{version}, 0, #{storeNewId}, #{aclId}, #{guid}, #{owner}, #{creator}, #{createdDate}, #{modifier}, #{modifiedDate}, #{accessDate}, #{isRoot}, #{layerId}, #{indirection}, #{indirectionVersion}, #{primaryIndirection}, #{opacity}, #{contentUrl}, #{mimetype}, #{encoding}, #{length}) insert into avm_version_roots (avm_store_id, root_id, version_id, creator, create_date, tag, description) - values (#storeId#, #rootNodeId#, #version#, #creator#, #createdDate#, #tag#, #description#) + values (#{storeId}, #{rootNodeId}, #{version}, #{creator}, #{createdDate}, #{tag}, #{description}) insert into avm_version_roots (id, avm_store_id, root_id, version_id, creator, create_date, tag, description) - values (#id#, #storeId#, #rootNodeId#, #version#, #creator#, #createdDate#, #tag#, #description#) + values (#{id}, #{storeId}, #{rootNodeId}, #{version}, #{creator}, #{createdDate}, #{tag}, #{description}) @@ -278,27 +260,27 @@ insert into avm_aspects (node_id, qname_id) - values (#nodeId#, #qnameId#) + values (#{nodeId}, #{qnameId}) insert into avm_child_entries (parent_id, name, child_id) - values (#parentNodeId#, #name#, #childNodeId#) + values (#{parentNodeId}, #{name}, #{childNodeId}) insert into avm_history_links (ancestor, descendent) - values (#ancestorNodeId#, #descendentNodeId#) + values (#{ancestorNodeId}, #{descendentNodeId}) insert into avm_merge_links (mfrom, mto) - values (#mergeFromNodeId#, #mergeToNodeId#) + values (#{mergeFromNodeId}, #{mergeToNodeId}) insert into avm_version_layered_node_entry (version_root_id, md5sum, path) - values (#versionRootId#, #md5sum#, #path#) + values (#{versionRootId}, #{md5sum}, #{path}) @@ -311,22 +293,22 @@ - select * from avm_stores where - name = #name# + name = #{name} - select * from avm_stores where - lower(name) = lower(#name#) + lower(name) = lower(#{name}) @@ -358,20 +340,20 @@ - + update avm_stores set - next_version_id = #nextVersion#, - name = #name#, - current_root_id = #rootNodeId#, - acl_id = #aclId#, - vers = #vers# + next_version_id = #{nextVersion}, + name = #{name,jdbcType=VARCHAR}, + current_root_id = #{rootNodeId,jdbcType=BIGINT}, + acl_id = #{aclId,jdbcType=BIGINT}, + vers = #{vers} where - id = #id# - - and vers = (#vers#-1) - + id = #{id} + + and vers = (#{vers} - 1) + @@ -387,14 +369,14 @@ - select * from avm_store_properties where - avm_store_id = #avmStoreId# and - qname_id = #qnameId# + avm_store_id = #{avmStoreId} and + qname_id = #{qnameId} - select id from @@ -553,7 +535,7 @@ class_type = 'layeredfile' - select content_url from @@ -573,90 +555,90 @@ - + update avm_nodes set - store_new_id = #storeNewId#, - acl_id = #aclId#, - layer_id = #layerId#, - version_id = #version#, - class_type = #classType#, - deletedType = #deletedType#, - owner = #owner#, - modDate = #modifiedDate#, - accessDate = #accessDate#, - is_root = #isRoot#, - lastModifier = #modifier#, - indirection = #indirection#, - indirection_version = #indirectionVersion#, - primary_indirection = #primaryIndirection#, - opacity = #opacity#, - content_url = #contentUrl#, - mime_type = #mimetype#, - encoding = #encoding#, - length = #length#, - guid = #guid#, - vers = #vers# + store_new_id = #{storeNewId,jdbcType=BIGINT}, + acl_id = #{aclId,jdbcType=BIGINT}, + layer_id = #{layerId,jdbcType=BIGINT}, + version_id = #{version}, + class_type = #{classType}, + deletedType = #{deletedType,jdbcType=INTEGER}, + owner = #{owner}, + modDate = #{modifiedDate}, + accessDate = #{accessDate}, + is_root = #{isRoot,jdbcType=BIT}, + lastModifier = #{modifier}, + indirection = #{indirection,jdbcType=VARCHAR}, + indirection_version = #{indirectionVersion,jdbcType=INTEGER}, + primary_indirection = #{primaryIndirection,jdbcType=BIT}, + opacity = #{opacity,jdbcType=BIT}, + content_url = #{contentUrl,jdbcType=VARCHAR}, + mime_type = #{mimetype,jdbcType=VARCHAR}, + encoding = #{encoding,jdbcType=VARCHAR}, + length = #{length,jdbcType=BIGINT}, + guid = #{guid,jdbcType=VARCHAR}, + vers = #{vers} where - id = #id# - - and vers = (#vers#-1) - + id = #{id} + + and vers = (#{vers} - 1) + - + update avm_nodes set - modDate = #modifiedDate#, - guid = #guid#, - vers = #vers# + modDate = #{modifiedDate}, + guid = #{guid,jdbcType=VARCHAR}, + vers = #{vers} where - id = #id# - - and vers = (#vers#-1) - + id = #{id} + + and vers = (#{vers} - 1) + - + update avm_nodes set - modDate = #modifiedDate#, - content_url = #contentUrl#, - mime_type = #mimetype#, - encoding = #encoding#, - length = #length#, - vers = #vers# + modDate = #{modifiedDate}, + content_url = #{contentUrl,jdbcType=VARCHAR}, + mime_type = #{mimetype,jdbcType=VARCHAR}, + encoding = #{encoding,jdbcType=VARCHAR}, + length = #{length,jdbcType=BIGINT}, + vers = #{vers} where - id = #id# - - and vers = (#vers#-1) - + id = #{id} + + and vers = (#{vers} - 1) + - + update avm_nodes set acl_id = null where acl_id is not null and id in - - #[]# - + + #{item} + - + update - avm_nodes set acl_id = #id# + avm_nodes set acl_id = #{id,jdbcType=BIGINT} where id in - - #listOfIds[]# - + + #{item} + @@ -671,14 +653,14 @@ - select * from avm_node_properties where - node_id = #nodeId# and - qname_id = #qnameId# + node_id = #{nodeId} and + qname_id = #{qnameId} + - select * from avm_version_roots where - avm_store_id = #id# + avm_store_id = #{id} and version_id = (select max(vr.version_id) from avm_version_roots vr where - vr.avm_store_id = #id# + vr.avm_store_id = #{id} ) @@ -773,14 +755,14 @@ root_id = ? - select * from avm_version_roots where - avm_store_id = #storeId# and - version_id = #version# + avm_store_id = #{storeId} and + version_id = #{version} - + update avm_version_roots set - tag = #tag#, - description = #description# + tag = #{tag}, + description = #{description} where - id = #id# + id = #{id} @@ -910,7 +892,7 @@ - select qname_id from @@ -920,13 +902,13 @@ - + delete from avm_aspects where - node_id = #nodeId# and - qname_id = #qnameId# + node_id = #{nodeId} and + qname_id = #{qnameId} @@ -942,26 +924,26 @@ - select * from avm_child_entries where - parent_id = #parentNodeId# and - name = #name# and - child_id = #childNodeId# + parent_id = #{parentNodeId} and + name = #{name} and + child_id = #{childNodeId} - select * from avm_child_entries where - parent_id = #parentNodeId# and - lower(name) = lower(#name#) and - child_id = #childNodeId# + parent_id = #{parentNodeId} and + lower(name) = lower(#{name}) and + child_id = #{childNodeId} @@ -1006,98 +988,98 @@ - select * from avm_child_entries where - parent_id = #parentNodeId# and - name = #name# + parent_id = #{parentNodeId} and + name = #{name} - select * from avm_child_entries where - parent_id = #parentNodeId# and - lower(name) = lower(#name#) + parent_id = #{parentNodeId} and + lower(name) = lower(#{name}) - select * from avm_child_entries where - parent_id = #parentNodeId# and - child_id = #childNodeId# + parent_id = #{parentNodeId} and + child_id = #{childNodeId} - + update avm_child_entries set - name = #name# + name = #{name} where - parent_id = #parentNodeId# and - child_id = #childNodeId# + parent_id = #{parentNodeId} and + child_id = #{childNodeId} - + delete from avm_child_entries where - parent_id = #parentNodeId# and - name = #name# + parent_id = #{parentNodeId} and + name = #{name} - + delete from avm_child_entries where - parent_id = #parentNodeId# and - lower(name) = lower(#name#) + parent_id = #{parentNodeId} and + lower(name) = lower(#{name}) - + delete from avm_child_entries where - parent_id = #parentNodeId# and - child_id = #childNodeId# + parent_id = #{parentNodeId} and + child_id = #{childNodeId} @@ -1142,13 +1124,13 @@ mto = ? - + delete from avm_merge_links where - mfrom = #mergeFromNodeId# and - mto = #mergeToNodeId# + mfrom = #{mergeFromNodeId} and + mto = #{mergeToNodeId} @@ -1173,23 +1155,23 @@ descendent = ? - select * from avm_history_links where - ancestor = #ancestorNodeId# and - descendent = #descendentNodeId# + ancestor = #{ancestorNodeId} and + descendent = #{descendentNodeId} - + delete from avm_history_links where - ancestor = #ancestorNodeId# and - descendent = #descendentNodeId# + ancestor = #{ancestorNodeId} and + descendent = #{descendentNodeId} @@ -1290,4 +1272,4 @@ ) - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/content-common-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/content-common-SqlMap.xml index 834c2a68a7..dfee36c5ed 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/content-common-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/content-common-SqlMap.xml @@ -1,40 +1,28 @@ - + - + - - - + - - - - - - - - - + - + - + @@ -43,7 +31,7 @@ - + @@ -58,16 +46,16 @@ - + - + - + @@ -75,7 +63,7 @@ - + @@ -89,12 +77,22 @@ insert into alf_mimetype (version, mimetype_str) - values (#version#, #mimetype#) + values (#{version}, #{mimetype}) + + + + insert into alf_mimetype (id, version, mimetype_str) + values (#{id}, #{version}, #{mimetype}) insert into alf_encoding (version, encoding_str) - values (#version#, #encoding#) + values (#{version}, #{encoding}) + + + + insert into alf_encoding (id, version, encoding_str) + values (#{id}, #{version}, #{encoding}) @@ -102,91 +100,101 @@ values (?, ?, ?, ?, ?) + + insert into alf_content_url (id, content_url, content_url_short, content_url_crc, content_size, orphan_time) + values (#{id}, #{contentUrl}, #{contentUrlShort}, #{contentUrlCrc}, #{size}, #{orphanTime,jdbcType=BIGINT}) + + insert into alf_content_data (version, content_url_id, content_mimetype_id, content_encoding_id, content_locale_id) values (?, ?, ?, ?, ?) + + insert into alf_content_data (id, version, content_url_id, content_mimetype_id, content_encoding_id, content_locale_id) + values (#{id}, #{version}, #{contentUrlId,jdbcType=BIGINT}, #{mimetypeId,jdbcType=BIGINT}, #{encodingId,jdbcType=BIGINT}, #{localeId,jdbcType=BIGINT}) + + - select * from alf_mimetype where - mimetype_str = #mimetype# + mimetype_str = #{mimetype} - select * from alf_mimetype where - id = #id# + id = #{id} - select * from alf_encoding where - encoding_str = #encoding# + encoding_str = #{encoding} - select * from alf_encoding where - id = #id# + id = #{id} - select * from alf_content_url where - id = #id# + id = #{id} - select * from alf_content_url where - content_url_short = #contentUrlShort# and - content_url_crc = #contentUrlCrc# + content_url_short = #{contentUrlShort} and + content_url_crc = #{contentUrlCrc} - select cu.* from alf_content_url cu left outer join alf_content_data cd on (cd.content_url_id = cu.id) where - content_url_short = #contentUrlShort# and - content_url_crc = #contentUrlCrc# and + content_url_short = #{contentUrlShort} and + content_url_crc = #{contentUrlCrc} and cd.id is null - 0 and - cu.orphan_time < #maxOrphanTimeExclusive# and + cu.orphan_time < #{maxOrphanTimeExclusive} and cu.orphan_time is not null ]]> - + update alf_mimetype set - mimetype_str = #mimetype# + mimetype_str = #{mimetype} where - id = #id# - - and version = (#version#-1) - + id = #{id} + + and version = (#{version} - 1) + - + update alf_content_url set - orphan_time = #orphanTime# + orphan_time = #{orphanTime,jdbcType=BIGINT} where - id = #id# and - orphan_time is null - orphan_time = #oldOrphanTime# + id = #{id} and + orphan_time is null + orphan_time = #{oldOrphanTime} - + delete from alf_content_url where id in - - #[]# - + + #{item} + @@ -257,31 +265,34 @@ - select np.long_value as id from alf_node_properties np where - np.node_id = #idOne# and - np.qname_id in #ids[]# and - (np.actual_type_n = 3 or np.actual_type_n = 21) + np.node_id = #{idOne} and + np.qname_id in + + #{item} + + and (np.actual_type_n = 3 or np.actual_type_n = 21) - + update alf_content_data set - version = #version#, - content_url_id = #contentUrlId#, - content_mimetype_id = #mimetypeId#, - content_encoding_id = #encodingId#, - content_locale_id = #localeId# + version = #{version}, + content_url_id = #{contentUrlId,jdbcType=BIGINT}, + content_mimetype_id = #{mimetypeId,jdbcType=BIGINT}, + content_encoding_id = #{encodingId,jdbcType=BIGINT}, + content_locale_id = #{localeId,jdbcType=BIGINT} where - id = #id# - - and version = (#version#-1) - + id = #{id} + + and version = (#{version} - 1) + @@ -293,4 +304,4 @@ id = ? - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/locale-common-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/locale-common-SqlMap.xml index 3def672a03..a8f8f921a3 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/locale-common-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/locale-common-SqlMap.xml @@ -1,22 +1,14 @@ - + - + - - - - - - - + @@ -26,11 +18,11 @@ - + - + @@ -40,9 +32,13 @@ insert into alf_locale (version, locale_str) - values (#version#, #localeStr#) + values (#{version}, #{localeStr}) + + insert into alf_locale (id, version, locale_str) + values (#{id}, #{version}, #{localeStr}) + @@ -66,4 +62,4 @@ locale_str = ? - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/locks-common-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/locks-common-SqlMap.xml index 6063c98044..3a1c81adc7 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/locks-common-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/locks-common-SqlMap.xml @@ -1,30 +1,21 @@ - + - - - - - - - - + - + - + @@ -38,7 +29,7 @@ - + @@ -52,12 +43,22 @@ insert into alf_lock_resource (version, qname_ns_id, qname_localname) - values (#version#, #qnameNamespaceId#, #qnameLocalName#) + values (#{version}, #{qnameNamespaceId}, #{qnameLocalName}) + + + + insert into alf_lock_resource (id, version, qname_ns_id, qname_localname) + values (#{id}, #{version}, #{qnameNamespaceId}, #{qnameLocalName}) insert into alf_lock (version, shared_resource_id, excl_resource_id, lock_token, start_time, expiry_time) - values (#version#, #sharedResourceId#, #exclusiveResourceId#, #lockToken#, #startTime#, #expiryTime#) + values (#{version}, #{sharedResourceId}, #{exclusiveResourceId}, #{lockToken}, #{startTime}, #{expiryTime}) + + + + insert into alf_lock (id, version, shared_resource_id, excl_resource_id, lock_token, start_time, expiry_time) + values (#{id}, #{version}, #{sharedResourceId}, #{exclusiveResourceId}, #{lockToken}, #{startTime}, #{expiryTime}) @@ -65,35 +66,35 @@ - select * from alf_lock_resource where - qname_ns_id = #qnameNamespaceId# and - qname_localname = #qnameLocalName# + qname_ns_id = #{qnameNamespaceId} and + qname_localname = #{qnameLocalName} - select * from alf_lock where - id = #id# + id = #{id} - select * from alf_lock where - shared_resource_id = #sharedResourceId# and - excl_resource_id = #exclusiveResourceId# + shared_resource_id = #{sharedResourceId} and + excl_resource_id = #{exclusiveResourceId} @@ -104,27 +105,25 @@ alf_lock where shared_resource_id in - - - #[]# - - + + #{item} + - + update alf_lock set - version = #version#, - lock_token = #lockToken#, - start_time = #startTime#, - expiry_time = #expiryTime# + version = #{version}, + lock_token = #{lockToken}, + start_time = #{startTime}, + expiry_time = #{expiryTime} where - id = #id# - - and version = (#version#-1) - + id = #{id} + + and version = (#{version} - 1) + @@ -141,4 +140,4 @@ lock_token = ? - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/node-common-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/node-common-SqlMap.xml index 8ee4cfb28c..73db1097e2 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/node-common-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/node-common-SqlMap.xml @@ -1,75 +1,53 @@ - + - + - - - - - - - - - - - - - - - - - - - - - + - - + + - + - + - + - + - + - + @@ -78,7 +56,7 @@ - + @@ -90,29 +68,31 @@ - + - + - + - + + - + - + - - - + + + @@ -120,7 +100,7 @@ - + @@ -132,7 +112,7 @@ - + @@ -148,23 +128,23 @@ - + - + - + - - - + + + @@ -172,11 +152,11 @@ - + - + @@ -187,69 +167,71 @@ insert into alf_server (version, ip_address) - values (#version#, #ipAddress#) + values (#{version}, #{ipAddress}) insert into alf_server (id, version, ip_address) - values (#id#, #version#, #ipAddress#) + values (#{id}, #{version}, #{ipAddress}) insert into alf_transaction (version, server_id, change_txn_id, commit_time_ms) - values (#version#, #server.id#, #changeTxnId#, #commitTimeMs#) + values (#{version}, #{server.id}, #{changeTxnId}, #{commitTimeMs}) insert into alf_transaction (id, version, server_id, change_txn_id, commit_time_ms) - values (#id#, #version#, #server.id#, #changeTxnId#, #commitTimeMs#) + values (#{id}, #{version}, #{server.id}, #{changeTxnId}, #{commitTimeMs}) insert into alf_store (version, protocol, identifier, root_node_id) - values (#version#, #protocol#, #identifier#, #rootNode.id#) + values (#{version}, #{protocol}, #{identifier}, #{rootNode.id,jdbcType=BIGINT}) + insert into alf_store (id, version, protocol, identifier, root_node_id) - values (#id#, #version#, #protocol#, #identifier#, #rootNode.id#) + values (#{id}, #{version}, #{protocol}, #{identifier}, #{rootNode.id,jdbcType=BIGINT}) insert into alf_node ( version, store_id, uuid, type_qname_id, acl_id, node_deleted, transaction_id - - audit_creator, audit_created, + + , audit_creator, audit_created, audit_modifier, audit_modified, audit_accessed - + ) values ( - #version#, #store.id#, #uuid#, #typeQNameId#, #aclId#, #deleted#, #transaction.id# - - #auditableProperties.auditCreator#, #auditableProperties.auditCreated#, - #auditableProperties.auditModifier#, #auditableProperties.auditModified#, - #auditableProperties.auditAccessed# - + #{version}, #{store.id}, #{uuid}, #{typeQNameId}, #{aclId,jdbcType=BIGINT}, #{deleted}, #{transaction.id} + + , #{auditableProperties.auditCreator,jdbcType=VARCHAR}, #{auditableProperties.auditCreated,jdbcType=VARCHAR}, + #{auditableProperties.auditModifier,jdbcType=VARCHAR}, #{auditableProperties.auditModified,jdbcType=VARCHAR}, + #{auditableProperties.auditAccessed,jdbcType=VARCHAR} + ) + insert into alf_node ( id, version, store_id, uuid, type_qname_id, acl_id, node_deleted, transaction_id - - audit_creator, audit_created, + + , audit_creator, audit_created, audit_modifier, audit_modified, audit_accessed - + ) values ( - #id#, #version#, #store.id#, #uuid#, #typeQNameId#, #aclId#, #deleted#, #transaction.id# - - #auditableProperties.auditCreator#, #auditableProperties.auditCreated#, - #auditableProperties.auditModifier#, #auditableProperties.auditModified#, - #auditableProperties.auditAccessed# - + #{id}, #{version}, #{store.id}, #{uuid}, #{typeQNameId}, #{aclId,jdbcType=BIGINT}, #{deleted}, #{transaction.id} + + , #{auditableProperties.auditCreator,jdbcType=VARCHAR}, #{auditableProperties.auditCreated,jdbcType=VARCHAR}, + #{auditableProperties.auditModifier,jdbcType=VARCHAR}, #{auditableProperties.auditModified,jdbcType=VARCHAR}, + #{auditableProperties.auditAccessed,jdbcType=VARCHAR} + ) @@ -263,10 +245,10 @@ ) values ( - #version#, #parentNode.id#, #childNode.id#, #typeQNameId#, - #childNodeNameCrc#, #childNodeName#, - #qnameNamespaceId#, #qnameLocalName#, #qnameCrc#, - #isPrimary#, #assocIndex# + #{version}, #{parentNode.id}, #{childNode.id}, #{typeQNameId}, + #{childNodeNameCrc}, #{childNodeName}, + #{qnameNamespaceId}, #{qnameLocalName}, #{qnameCrc}, + #{isPrimary}, #{assocIndex} ) @@ -279,20 +261,20 @@ ) values ( - #id#, #version#, #parentNode.id#, #childNode.id#, #typeQNameId#, - #childNodeNameCrc#, #childNodeName#, - #qnameNamespaceId#, #qnameLocalName#, #qnameCrc#, - #isPrimary#, #assocIndex# + #{id}, #{version}, #{parentNode.id}, #{childNode.id}, #{typeQNameId}, + #{childNodeNameCrc}, #{childNodeName}, + #{qnameNamespaceId}, #{qnameLocalName}, #{qnameCrc}, + #{isPrimary}, #{assocIndex} ) insert into alf_node_assoc (version, source_node_id, target_node_id, type_qname_id) - values (#version#, #sourceNode.id#, #targetNode.id#, #typeQNameId#) + values (#{version}, #{sourceNode.id}, #{targetNode.id}, #{typeQNameId}) insert into alf_node_assoc (id, version, source_node_id, target_node_id, type_qname_id) - values (#id#, #version#, #sourceNode.id#, #targetNode.id#, #typeQNameId#) + values (#{id}, #{version}, #{sourceNode.id}, #{targetNode.id}, #{typeQNameId}) @@ -326,185 +308,195 @@ - + update alf_transaction set - commit_time_ms = #commitTimeMs# + commit_time_ms = #{commitTimeMs} where - id = #id# + id = #{id} - + update alf_store set - root_node_id = #rootNode.id# + root_node_id = #{rootNode.id,jdbcType=BIGINT} where - id = #id# + id = #{id} - + update alf_store set - protocol = #protocol#, - identifier = #identifier# + protocol = #{protocol}, + identifier = #{identifier} where - id = #id# + id = #{id} - + update alf_node set - version = #version# - , store_id = #store.id# - , uuid = #uuid# - , type_qname_id = #typeQNameId# - , acl_id = #aclId# - , node_deleted = #deleted# - , transaction_id = #transaction.id# - - , audit_creator = #auditableProperties.auditCreator# - , audit_created = #auditableProperties.auditCreated# - , audit_modifier = #auditableProperties.auditModifier# - , audit_modified = #auditableProperties.auditModified# - , audit_accessed = #auditableProperties.auditAccessed# - + version = #{version} + , store_id = #{store.id} + , uuid = #{uuid} + , type_qname_id = #{typeQNameId} + , acl_id = #{aclId,jdbcType=BIGINT} + , node_deleted = #{deleted} + , transaction_id = #{transaction.id} + + , audit_creator = #{auditableProperties.auditCreator,jdbcType=VARCHAR} + , audit_created = #{auditableProperties.auditCreated,jdbcType=VARCHAR} + , audit_modifier = #{auditableProperties.auditModifier,jdbcType=VARCHAR} + , audit_modified = #{auditableProperties.auditModified,jdbcType=VARCHAR} + , audit_accessed = #{auditableProperties.auditAccessed,jdbcType=VARCHAR} + where - id = #id# - - and version = (#version#-1) - + id = #{id} + + and version = (#{version} - 1) + - + update alf_node set - acl_id = #aclId# + acl_id = #{aclId,jdbcType=BIGINT} where - id = #id# + id = #{id} - + update alf_child_assoc set - child_node_name_crc = #childNodeNameCrc#, - child_node_name = #childNodeName# + child_node_name_crc = #{childNodeNameCrc}, + child_node_name = #{childNodeName} where - child_node_id = #childNode.id# and + child_node_id = #{childNode.id} and child_node_name_crc > 0 - + update alf_child_assoc set - assoc_index = #assocIndex# + assoc_index = #{assocIndex} where - parent_node_id = #parentNode.id# and - type_qname_id = #typeQNameId# and - qname_ns_id = #qnameNamespaceId# and - qname_localname = #qnameLocalName# and - child_node_id = #childNode.id# + parent_node_id = #{parentNode.id} and + type_qname_id = #{typeQNameId} and + qname_ns_id = #{qnameNamespaceId} and + qname_localname = #{qnameLocalName} and + child_node_id = #{childNode.id} - + update alf_child_assoc set - parent_node_id = #parentNode.id# - , type_qname_id = #typeQNameId# - , child_node_name_crc = #childNodeNameCrc# - , child_node_name = #childNodeName# - , qname_ns_id = #qnameNamespaceId# - , qname_localname = #qnameLocalName# - , qname_crc = #qnameCrc# + parent_node_id = #{parentNode.id} + , type_qname_id = #{typeQNameId} + , child_node_name_crc = #{childNodeNameCrc} + , child_node_name = #{childNodeName} + , qname_ns_id = #{qnameNamespaceId} + , qname_localname = #{qnameLocalName} + , qname_crc = #{qnameCrc} where - child_node_id = #childNode.id# and - is_primary = #isPrimary# + child_node_id = #{childNode.id} and + is_primary = #{isPrimary} - + delete from alf_transaction where - id = #id# + id = #{id} - + delete from alf_node where - id = #id# - and node_deleted = #deleted# + id = #{id} + and node_deleted = #{deleted} - + - + delete from alf_node_properties where - node_id = #nodeId# - and qname_id = #key.qnameId# - and locale_id = #key.localeId# - and list_index = #key.listIndex# - + node_id = #{nodeId} + + and qname_id = #{key.qnameId} + and locale_id = #{key.localeId} + and list_index = #{key.listIndex} + + and qname_id in - #qnameIds[]# - + + #{item} + + - + delete from alf_node_aspects where - node_id = #nodeId# - + node_id = #{nodeId} + and qname_id in - #aspectQNameIds[]# - + + #{item} + + - + delete from alf_node_assoc where - source_node_id = #sourceNode.id# and - target_node_id = #targetNode.id# and - type_qname_id = #typeQNameId# + source_node_id = #{sourceNode.id} and + target_node_id = #{targetNode.id} and + type_qname_id = #{typeQNameId} - + delete from alf_node_assoc where - (source_node_id = #sourceNode.id# or target_node_id = #targetNode.id#) - + (source_node_id = #{sourceNode.id} or target_node_id = #{targetNode.id}) + and type_qname_id in - #typeQNameIds[]# - + + #{item} + + - + delete from alf_child_assoc where - id = #id# + id = #{id} - + delete from alf_child_assoc where - (parent_node_id = #parentNode.id# or child_node_id = #childNode.id#) - + (parent_node_id = #{parentNode.id} or child_node_id = #{childNode.id}) + and type_qname_id in - #typeQNameIds[]# - + + #{item} + + - select id, version, @@ -512,7 +504,7 @@ from alf_server where - ip_address = #ipAddress# + ip_address = #{ipAddress} - select node.id as id, store.id as storeId, @@ -535,10 +527,10 @@ alf_store store join alf_node node on (store.root_node_id = node.id) where - store.id = #id# + store.id = #{id} - select node.id as id, store.id as storeId, @@ -549,8 +541,8 @@ alf_store store join alf_node node on (store.root_node_id = node.id) where - store.protocol = #protocol# and - store.identifier = #identifier# + store.protocol = #{protocol} and + store.identifier = #{identifier} @@ -574,39 +566,42 @@ node.audit_accessed as audit_accessed - from alf_node node join alf_store store on (store.id = node.store_id) join alf_transaction txn on (txn.id = node.transaction_id) where - node.id = #id# - and node.node_deleted = #deleted# + node.id = #{id} + and node.node_deleted = #{deleted} - from alf_node node join alf_store store on (store.id = node.store_id) join alf_transaction txn on (txn.id = node.transaction_id) where - store.protocol = #store.protocol# and - store.identifier = #store.identifier# and - node.uuid = #uuid# - and node.node_deleted = #deleted# + store.protocol = #{store.protocol} and + store.identifier = #{store.identifier} and + node.uuid = #{uuid} + and node.node_deleted = #{deleted} - from alf_node node join alf_store store on (store.id = node.store_id) join alf_transaction txn on (txn.id = node.transaction_id) where - node.store_id = #storeId# and - node.uuid in #uuids[]# + node.store_id = #{storeId} and + node.uuid in + + #{item} + @@ -625,22 +620,26 @@ prop.serializable_value as serializable_value - from alf_node_properties prop - where - - prop.node_id = #nodeId# - - node_id in #nodeIds[]# - - - and qname_id = #key.qnameId# - + + prop.node_id = #{nodeId} + + and node_id in + + #{item} + + + and qname_id = #{key.qnameId} + and qname_id in - #qnameIds[]# - + + #{item} + + + @@ -649,24 +648,28 @@ aspects.qname_id as qname_id - from alf_node_aspects aspects - where - - aspects.node_id = #nodeId# - - aspects.node_id in #nodeIds[]# - - + + aspects.node_id = #{nodeId} + + and aspects.node_id in + + #{item} + + + + - where - targetNode.id = #targetNode.id# + targetNode.id = #{targetNode.id} - where - assoc.id = #id# + assoc.id = #{id} @@ -757,45 +760,54 @@ assoc.id ASC - where - assoc.id = #id# + assoc.id = #{id} - where - parentNode.id = #parentNode.id# - and assoc.child_node_id = #childNode.id# - - and assoc.type_qname_id in #typeQNameIds[]# - - and assoc.type_qname_id = #typeQNameId# - and assoc.qname_crc = #qnameCrc# - and assoc.qname_ns_id = #qnameNamespaceId# - and assoc.qname_localname = #qnameLocalName# - and assoc.is_primary = #isPrimary# - and assoc.child_node_name = #childNodeName# - and assoc.child_node_name_crc = #childNodeNameCrc# - - and child_node_name_crc in #childNodeNameCrcs[]# - - - and childNode.type_qname_id in #childNodeTypeQNameIds[]# - - - and parentStore.id = childStore.id - childStore.id]]> - - + parentNode.id = #{parentNode.id} + and assoc.child_node_id = #{childNode.id} + + and assoc.type_qname_id in + + #{item} + + + and assoc.type_qname_id = #{typeQNameId} + and assoc.qname_crc = #{qnameCrc} + and assoc.qname_ns_id = #{qnameNamespaceId} + and assoc.qname_localname = #{qnameLocalName} + and assoc.is_primary = #{isPrimary} + and assoc.child_node_name = #{childNodeName} + and assoc.child_node_name_crc = #{childNodeNameCrc} + + and child_node_name_crc in + + #{item} + + + + and childNode.type_qname_id in + + #{item} + + + + and parentStore.id = childStore.id + childStore.id]]> + + - + - from ( @@ -808,29 +820,29 @@ LEFT OUTER JOIN ( alf_child_assoc a - JOIN alf_child_assoc z2 ON (z2.parent_node_id = #parentNode.id# AND z2.child_node_id = a.parent_node_id ) + JOIN alf_child_assoc z2 ON (z2.parent_node_id = #{parentNode.id} AND z2.child_node_id = a.parent_node_id ) ) - ON (a.child_node_id = childNode.id AND a.type_qname_id = #typeQNameId#) + ON (a.child_node_id = childNode.id AND a.type_qname_id = #{typeQNameId}) where - parentNode.id = #parentNode.id# and + parentNode.id = #{parentNode.id} and a.child_node_id IS NULL - join alf_node_properties prop on (childNode.id = prop.node_id) where - parentNode.id = #parentNodeId# - and prop.qname_id = #propertyQNameId# - and prop.string_value = #value.stringValue# - and prop.double_value = #value.doubleValue# - and prop.long_value = #value.longValue# - and prop.boolean_value = #value.booleanValue# + parentNode.id = #{parentNodeId} + and prop.qname_id = #{propertyQNameId} + and prop.string_value = #{value.stringValue} + and prop.double_value = #{value.doubleValue} + and prop.long_value = #{value.longValue} + and prop.boolean_value = #{value.booleanValue} - select node.id as id, node.acl_id as acl_id @@ -839,25 +851,28 @@ join alf_child_assoc assoc on ( node.id = assoc.child_node_id - and assoc.parent_node_id = #parentNode.id# - and assoc.is_primary = #isPrimary# + and assoc.parent_node_id = #{parentNode.id} + and assoc.is_primary = #{isPrimary} ) - where - childNode.id = #childNode.id# - and assoc.parent_node_id = #parentNode.id# - - and type_qname_id in #typeQNameIds[]# - - and assoc.type_qname_id = #typeQNameId# - and assoc.qname_crc = #qnameCrc# - and assoc.qname_ns_id = #qnameNamespaceId# - and assoc.qname_localname = #qnameLocalName# - and assoc.is_primary = #isPrimary# + childNode.id = #{childNode.id} + and assoc.parent_node_id = #{parentNode.id} + + and type_qname_id in + + #{item} + + + and assoc.type_qname_id = #{typeQNameId} + and assoc.qname_crc = #{qnameCrc} + and assoc.qname_ns_id = #{qnameNamespaceId} + and assoc.qname_localname = #{qnameLocalName} + and assoc.is_primary = #{isPrimary} @@ -869,29 +884,35 @@ - order by txn.commit_time_ms ASC, txn.id ASC - order by txn.commit_time_ms DESC, txn.id DESC + order by txn.commit_time_ms ASC, txn.id ASC + order by txn.commit_time_ms DESC, txn.id DESC - - txn.id = #id# - node.node_deleted = #deletedNodes# - store.id = #storeId# - #excludeServerId#]]> - = #minCommitTime#]]> - - - txn.id in #includeTxnIds[]# - - - txn.id NOT in #excludeTxnIds[]# - - + + txn.id = #{id} + and node.node_deleted = #{deletedNodes} + and store.id = #{storeId} + #{excludeServerId}]]> + = #{minCommitTime}]]> + + + and txn.id in + + #{item} + + + + and txn.id NOT in + + #{item} + + + - from alf_transaction txn @@ -899,11 +920,11 @@ txn.commit_time_ms = ( select max(commit_time_ms) from alf_transaction - + ) - select node.id as id, store.protocol as protocol, @@ -920,7 +941,7 @@ order by node.id - from alf_transaction txn @@ -928,24 +949,24 @@ - select count(txn.id) from alf_transaction txn - select count(node.id) from alf_node node where - node.transaction_id = #transaction.id# - and node.node_deleted = #deleted# + node.transaction_id = #{transaction.id} + and node.node_deleted = #{deleted} - select txn.id from @@ -953,24 +974,24 @@ left join alf_node node on (node.transaction_id = txn.id) where node.id is null - = #minId#]]> - + = #{minId}]]> + order by txn.id ASC - select min(commit_time_ms) from alf_transaction - select max(commit_time_ms) from alf_transaction - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/node-update-acl-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/node-update-acl-SqlMap.xml index 0e73152fc6..803eed8936 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/node-update-acl-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/node-update-acl-SqlMap.xml @@ -1,33 +1,31 @@ - + - + - + update alf_node set - acl_id = #newSharedAclId# + acl_id = #{newSharedAclId} where id in ( select n.id from alf_node n - join alf_child_assoc ca on (n.id = ca.child_node_id and ca.is_primary = #isPrimary#) + join alf_child_assoc ca on (n.id = ca.child_node_id and ca.is_primary = #{isPrimary}) where - ca.parent_node_id = #primaryParentNodeId# + ca.parent_node_id = #{primaryParentNodeId} and ( n.acl_id is null - OR n.acl_id = #optionalOldSharedAclIdInAdditionToNull# + OR n.acl_id = #{optionalOldSharedAclIdInAdditionToNull} ) ) - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/patch-common-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/patch-common-SqlMap.xml index 6178837e5d..ce22fefeab 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/patch-common-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/patch-common-SqlMap.xml @@ -1,24 +1,14 @@ - + - + - - - - - - - - - + @@ -26,12 +16,12 @@ - + - + @@ -42,44 +32,44 @@ - + - + - + - + - + - + - + @@ -87,7 +77,7 @@ - + @@ -98,11 +88,11 @@ - + - + @@ -110,24 +100,24 @@ - + - + - + - + @@ -137,23 +127,23 @@ - select max(id) from avm_nodes - select max(id) from alf_node - = #idOne# - and id < #idTwo# + id >= #{idOne} + and id < #{idTwo} and class_type = 'plainfile' and content_url is not null and content_url not like 'id:%' @@ -162,7 +152,7 @@ ]]> - = #idOne# - and node_id < #idTwo# + node_id >= #{idOne} + and node_id < #{idTwo} and actual_type_n = 11 order by node_id ASC @@ -189,15 +179,15 @@ alf_authority - select count(*) from alf_child_assoc - select max(id) from alf_child_assoc - = #idTwo# and - ca.id < #idThree# + ca.id >= #{idTwo} and + ca.id < #{idThree} order by ca.id ASC ]]> @@ -231,9 +221,9 @@ join alf_store s on (s.id = n.store_id) join alf_node_properties np on (np.node_id = n.id) where - n.type_qname_id = #typeQNameId# and - np.qname_id = #propQNameId# and - np.string_value like #namePattern# + n.type_qname_id = #{typeQNameId} and + np.qname_id = #{propQNameId} and + np.string_value like #{namePattern} - select ga.name as name from @@ -311,7 +301,7 @@ name not in ('alfresco-tenants', '.href', '.avm_lock_table', '.PropertyBackedBeans', '.ChainingUserRegistrySynchronizer') - select id from @@ -319,7 +309,7 @@ - select acl_id from avm_nodes where acl_id is not null union select acl_id from avm_stores where acl_id is not null union select acl_id from alf_node where acl_id is not null @@ -327,7 +317,7 @@ - select max(acl.id) from @@ -335,7 +325,7 @@ - select count(*) from @@ -343,7 +333,7 @@ - select count(*) from @@ -377,7 +367,7 @@ ]]> - - - - - - + INSERT INTO alf_node_properties ( node_id, actual_type_n, persisted_type_n, @@ -571,22 +561,22 @@ qname_id, list_index, locale_id) SELECT n.id, 0, 0, - #false#, + #{false}, 0, 0, 0, null, null, - #sizeCurrentQNameId#, -1, #defaultLocaleId# + #{sizeCurrentQNameId}, -1, #{defaultLocaleId} FROM alf_node n WHERE - n.type_qname_id = #personTypeQNameId# + n.type_qname_id = #{personTypeQNameId} AND NOT EXISTS ( SELECT 1 FROM alf_node_properties np WHERE np.node_id = n.id - AND np.qname_id = #sizeCurrentQNameId# + AND np.qname_id = #{sizeCurrentQNameId} ) @@ -610,4 +600,4 @@ delete from alf_attributes - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/permissions-common-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/permissions-common-SqlMap.xml index 7483422c28..78144f533d 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/permissions-common-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/permissions-common-SqlMap.xml @@ -1,29 +1,16 @@ - + - + + + - - - - - - - - - - - - - - + @@ -31,37 +18,37 @@ - + - + - + - + - + - + - + @@ -69,33 +56,33 @@ - + - + - + - + - + - + @@ -104,34 +91,34 @@ - + - + - + - + - + - + - + @@ -143,8 +130,8 @@ (version, acl_id, latest, acl_version, inherits, inherits_from, type, inherited_acl, is_versioned, requires_version, acl_change_set) values - (#version#, #aclId#, #latest#, #aclVersion#, #inherits#, #inheritsFrom#, - #type#, #inheritedAcl#, #isVersioned#, #requiresVersion#, #aclChangeSet#) + (#{version}, #{aclId}, #{latest}, #{aclVersion}, #{inherits}, #{inheritsFrom}, + #{type}, #{inheritedAcl}, #{isVersioned}, #{requiresVersion}, #{aclChangeSet}) @@ -152,106 +139,106 @@ (id, version, acl_id, latest, acl_version, inherits, inherits_from, type, inherited_acl, is_versioned, requires_version, acl_change_set) values - (#id#, #version#, #aclId#, #latest#, #aclVersion#, #inherits#, #inheritsFrom#, - #type#, #inheritedAcl#, #isVersioned#, #requiresVersion#, #aclChangeSet#) + (#{id}, #{version}, #{aclId}, #{latest}, #{aclVersion}, #{inherits}, #{inheritsFrom}, + #{type}, #{inheritedAcl}, #{isVersioned}, #{requiresVersion}, #{aclChangeSet}) insert into alf_acl_member (version, acl_id, ace_id, pos) values - (#version#, #aclId#, #aceId#, #pos#) + (#{version}, #{aclId}, #{aceId}, #{pos}) insert into alf_acl_member (id, version, acl_id, ace_id, pos) values - (#id#, #version#, #aclId#, #aceId#, #pos#) + (#{id}, #{version}, #{aclId}, #{aceId}, #{pos}) insert into alf_acl_change_set (version) values - (#version#) + (#{version}) insert into alf_acl_change_set (id, version) values - (#id#, #version#) + (#{id}, #{version}) insert into alf_access_control_entry (version, permission_id, authority_id, allowed, applies, context_id) values - (#version#, #permissionId#, #authorityId#, #allowed#, #applies#, #contextId#) + (#{version}, #{permissionId}, #{authorityId}, #{allowed}, #{applies}, #{contextId}) insert into alf_access_control_entry (id, version, permission_id, authority_id, allowed, applies, context_id) values - (#id#, #version#, #permissionId#, #authorityId#, #allowed#, #applies#, #contextId#) + (#{id}, #{version}, #{permissionId}, #{authorityId}, #{allowed}, #{applies}, #{contextId}) insert into alf_ace_context (version, class_context, property_context, kvp_context) values - (#version#, #classContext#, #propertyContext#, #kvpContext#) + (#{version}, #{classContext}, #{propertyContext}, #{kvpContext}) insert into alf_ace_context (id, version, class_context, property_context, kvp_context) values - (#id#, #version#, #classContext#, #propertyContext#, #kvpContext#) + (#{id}, #{version}, #{classContext}, #{propertyContext}, #{kvpContext}) insert into alf_permission (version, type_qname_id, name) values - (#version#, #typeQnameId#, #name#) + (#{version}, #{typeQnameId}, #{name}) insert into alf_permission (id, version, type_qname_id, name) values - (#id#, #version#, #typeQnameId#, #name#) + (#{id}, #{version}, #{typeQnameId}, #{name}) insert into alf_authority (version, authority, crc) values - (#version#, #authority#, #crc#) + (#{version}, #{authority}, #{crc}) insert into alf_authority (id, version, authority, crc) values - (#id#, #version#, #authority#, #crc#) + (#{id}, #{version}, #{authority}, #{crc}) insert into alf_authority_alias (version, auth_id, alias_id) values - (#version#, #authId#, #aliasId#) + (#{version}, #{authId}, #{aliasId}) insert into alf_authority_alias (id, version, auth_id, alias_id) values - (#id#, #version#, #authId#, #aliasId#) + (#{id}, #{version}, #{authId}, #{aliasId}) @@ -259,73 +246,74 @@ + - + update alf_access_control_list set - acl_id = #aclId#, - latest = #latest#, - acl_version = #aclVersion#, - inherits = #inherits#, - inherits_from = #inheritsFrom#, - type = #type#, - inherited_acl = #inheritedAcl#, - is_versioned = #isVersioned#, - requires_version = #requiresVersion#, - acl_change_set = #aclChangeSet#, - version = #version# + acl_id = #{aclId}, + latest = #{latest}, + acl_version = #{aclVersion}, + inherits = #{inherits}, + inherits_from = #{inheritsFrom,jdbcType=BIGINT}, + type = #{type}, + inherited_acl = #{inheritedAcl,jdbcType=BIGINT}, + is_versioned = #{isVersioned}, + requires_version = #{requiresVersion}, + acl_change_set = #{aclChangeSet,jdbcType=BIGINT}, + version = #{version} where - id = #id# - - and version = (#version#-1) - + id = #{id} + + and version = (#{version} - 1) + - + update alf_acl_member set - acl_id = #aclId#, - ace_id = #aceId#, - pos = #pos#, - version = #version# + acl_id = #{aclId}, + ace_id = #{aceId}, + pos = #{pos}, + version = #{version} where - id = #id# - - and version = (#version#-1) - + id = #{id} + + and version = (#{version} - 1) + - + update alf_authority set - authority = #authority#, - crc = #crc#, - version = #version# + authority = #{authority}, + crc = #{crc}, + version = #{version} where - id = #id# - - and version = (#version#-1) - + id = #{id} + + and version = (#{version} - 1) + - + update alf_permission set - type_qname_id = #typeQnameId#, - name = #name#, - version = #version# + type_qname_id = #{typeQnameId}, + name = #{name}, + version = #{version} where - id = #id# - - and version = (#version#-1) - + id = #{id} + + and version = (#{version} - 1) + @@ -341,7 +329,7 @@ id = ? - select acl.id from @@ -350,7 +338,7 @@ acl.inherits_from = ? and acl.inherits = ? - select acl.id from @@ -359,7 +347,7 @@ acl.acl_id = ? and acl.latest = ? - select id from @@ -368,7 +356,7 @@ acl_id = ? - select id from @@ -508,26 +496,26 @@ - + delete from alf_access_control_list where id in - - #[]# - + + #{item} + - + delete from alf_access_control_entry where id in - - #[]# - + + #{item} + @@ -545,15 +533,15 @@ ) - + delete from alf_acl_member where id in - - #[]# - + + #{item} + @@ -565,15 +553,15 @@ - + delete from alf_acl_member where acl_id in - - #[]# - + + #{item} + @@ -616,4 +604,4 @@ id = ? - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/propval-common-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/propval-common-SqlMap.xml index eb4712f70a..4bbfa01620 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/propval-common-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/propval-common-SqlMap.xml @@ -1,40 +1,22 @@ - + - + - - - + - - - - - - - - - - - - - - - - + + - + @@ -47,49 +29,49 @@ - + - + - + - + - + - + - + - + - + - + @@ -97,7 +79,7 @@ - + @@ -111,27 +93,27 @@ - + - + - + - - + + - + - - + + @@ -141,17 +123,32 @@ insert into alf_prop_class (java_class_name, java_class_name_short, java_class_name_crc) - values (#javaClassName#, #javaClassNameShort#, #javaClassNameCrc#) + values (#{javaClassName}, #{javaClassNameShort}, #{javaClassNameCrc}) + + + + insert into alf_prop_class (id, java_class_name, java_class_name_short, java_class_name_crc) + values (#{id}, #{javaClassName}, #{javaClassNameShort}, #{javaClassNameCrc}) insert into alf_prop_string_value (string_value, string_end_lower, string_crc) - values (#stringValue#, #stringEndLower#, #stringCrc#) + values (#{stringValue}, #{stringEndLower}, #{stringCrc}) + + + + insert into alf_prop_string_value (id, string_value, string_end_lower, string_crc) + values (#{id}, #{stringValue}, #{stringEndLower}, #{stringCrc}) insert into alf_prop_double_value (double_value) - values (#doubleValue#) + values (#{doubleValue}) + + + + insert into alf_prop_double_value (id, double_value) + values (#{id}, #{doubleValue}) @@ -159,15 +156,26 @@ values (?) + + insert into alf_prop_serializable_value (id, serializable_value) + values (?, ?) + + insert into alf_prop_value (actual_type_id, persisted_type, long_value) - values (#actualTypeId#, #persistedType#, #longValue#) + values (#{actualTypeId}, #{persistedType}, #{longValue}) + + + + insert into alf_prop_value (id, actual_type_id, persisted_type, long_value) + values (#{id}, #{actualTypeId}, #{persistedType}, #{longValue}) insert into alf_prop_root (version) values (?) + insert into alf_prop_root (id, version) values (?, ?) @@ -175,11 +183,12 @@ insert into alf_prop_unique_ctx (version, value1_prop_id, value2_prop_id, value3_prop_id, prop1_id) - values (#version#, #value1PropId#, #value2PropId#, #value3PropId#, #propertyId#) + values (#{version}, #{value1PropId}, #{value2PropId}, #{value3PropId}, #{propertyId,jdbcType=BIGINT}) + insert into alf_prop_unique_ctx (id, version, value1_prop_id, value2_prop_id, value3_prop_id, prop1_id) - values (#id#, #version#, #value1PropId#, #value2PropId#, #value3PropId#, #propertyId#) + values (#{id}, #{version}, #{value1PropId}, #{value2PropId}, #{value3PropId}, #{propertyId,jdbcType=BIGINT}) @@ -187,27 +196,27 @@ - select * from alf_prop_class where - id = #id# + id = #{id} - select * from alf_prop_class where - java_class_name_crc = #javaClassNameCrc# and - java_class_name_short = #javaClassNameShort# + java_class_name_crc = #{javaClassNameCrc} and + java_class_name_short = #{javaClassNameShort} - + insert into alf_prop_date_value ( date_value, @@ -218,88 +227,88 @@ ) values ( - #dateValue#, - #fullYear#, #halfOfYear#, #quarterOfYear#, - #monthOfYear#, - #weekOfYear#, #weekOfMonth#, - #dayOfYear#, #dayOfMonth#, #dayOfWeek# + #{dateValue}, + #{fullYear}, #{halfOfYear}, #{quarterOfYear}, + #{monthOfYear}, + #{weekOfYear}, #{weekOfMonth}, + #{dayOfYear}, #{dayOfMonth}, #{dayOfWeek} ) - select * from alf_prop_date_value where - date_value = #dateValue# + date_value = #{dateValue} - select * from alf_prop_date_value where - date_value = #dateValue# + date_value = #{dateValue} - select string_value from alf_prop_string_value where - id = #id# + id = #{id} - select id from alf_prop_string_value where - string_end_lower = #stringEndLower# and - string_crc = #stringCrc# + string_end_lower = #{stringEndLower} and + string_crc = #{stringCrc} - select * from alf_prop_double_value where - id = #id# + id = #{id} - select * from alf_prop_double_value where - double_value = #doubleValue# + double_value = #{doubleValue} - select * from alf_prop_serializable_value where - id = #id# + id = #{id} - select pv.id as prop_id, pv.actual_type_id as prop_actual_type_id, @@ -308,12 +317,12 @@ from alf_prop_value pv where - pv.actual_type_id = #actualTypeId# and - pv.long_value = #longValue# + pv.actual_type_id = #{actualTypeId} and + pv.long_value = #{longValue} - select pv.id as prop_id, pv.actual_type_id as prop_actual_type_id, @@ -322,14 +331,14 @@ dv.double_value as prop_double_value from alf_prop_value pv - join alf_prop_double_value dv on (dv.id = pv.long_value and pv.persisted_type = #persistedType#) + join alf_prop_double_value dv on (dv.id = pv.long_value and pv.persisted_type = #{persistedType}) where - pv.actual_type_id = #actualTypeId# and - dv.double_value = #doubleValue# + pv.actual_type_id = #{actualTypeId} and + dv.double_value = #{doubleValue} - select pv.id as prop_id, pv.actual_type_id as prop_actual_type_id, @@ -338,15 +347,15 @@ sv.string_value as prop_string_value from alf_prop_value pv - join alf_prop_string_value sv on (sv.id = pv.long_value and pv.persisted_type = #persistedType#) + join alf_prop_string_value sv on (sv.id = pv.long_value and pv.persisted_type = #{persistedType}) where - pv.actual_type_id = #actualTypeId# and - sv.string_end_lower = #stringEndLower# and - sv.string_crc = #stringCrc# + pv.actual_type_id = #{actualTypeId} and + sv.string_end_lower = #{stringEndLower} and + sv.string_crc = #{stringCrc} - select pv.id as prop_id, pv.actual_type_id as prop_actual_type_id, @@ -361,11 +370,11 @@ left join alf_prop_string_value sv on (sv.id = pv.long_value and (pv.persisted_type = 3 OR pv.persisted_type = 5 OR pv.persisted_type = 6)) left join alf_prop_serializable_value serv on (serv.id = pv.long_value and pv.persisted_type = 4) where - pv.id = #id# + pv.id = #{id} - select pl.root_prop_id as link_root_prop_id, pl.prop_index as link_prop_index, @@ -385,11 +394,11 @@ left join alf_prop_string_value sv on (sv.id = pv.long_value and (pv.persisted_type = 3 OR pv.persisted_type = 5 OR pv.persisted_type = 6)) left join alf_prop_serializable_value serv on (serv.id = pv.long_value and pv.persisted_type = 4) where - pl.root_prop_id = #id# + pl.root_prop_id = #{id} - select pl.root_prop_id as prop_id, pl.root_prop_id as link_root_prop_id, @@ -409,63 +418,62 @@ left join alf_prop_double_value dv on (dv.id = pv.long_value and pv.persisted_type = 2) left join alf_prop_string_value sv on (sv.id = pv.long_value and (pv.persisted_type = 3 OR pv.persisted_type = 5 OR pv.persisted_type = 6)) left join alf_prop_serializable_value serv on (serv.id = pv.long_value and pv.persisted_type = 4) - - - #rootPropIds[]# - - - order by - root_prop_id + where pl.root_prop_id in + + #{item} + + order by + root_prop_id - select id, version from alf_prop_root where - id = #id# + id = #{id} - + update alf_prop_root set - version = #version# + version = #{version} where - id = #id# - - and version = (#version#-1) - + id = #{id} + + and version = (#{version} - 1) + - + delete from alf_prop_root where - id = #id# + id = #{id} - + insert into alf_prop_link ( root_prop_id, prop_index, contained_in, key_prop_id, value_prop_id ) values ( - #rootPropId#, #propIndex#, #containedIn#, #keyPropId#, #valuePropId# + #{rootPropId}, #{propIndex}, #{containedIn}, #{keyPropId}, #{valuePropId} ) - + delete from alf_prop_link where - root_prop_id = #id# + root_prop_id = #{id} - select id, version, @@ -476,10 +484,10 @@ from alf_prop_unique_ctx where - id = #id# + id = #{id} - select id, version, @@ -490,49 +498,49 @@ from alf_prop_unique_ctx where - value1_prop_id = #value1PropId# - - and value2_prop_id = #value2PropId# - - - and value3_prop_id = #value3PropId# - + value1_prop_id = #{value1PropId} + + and value2_prop_id = #{value2PropId} + + + and value3_prop_id = #{value3PropId} + - + update alf_prop_unique_ctx set - version = #version#, - value1_prop_id = #value1PropId#, - value2_prop_id = #value2PropId#, - value3_prop_id = #value3PropId#, - prop1_id = #propertyId# + version = #{version}, + value1_prop_id = #{value1PropId}, + value2_prop_id = #{value2PropId}, + value3_prop_id = #{value3PropId}, + prop1_id = #{propertyId,jdbcType=BIGINT} where - id = #id# - - and version = (#version#-1) - + id = #{id} + + and version = (#{version} - 1) + - + delete from alf_prop_unique_ctx where - id = #id# + id = #{id} - + delete from alf_prop_unique_ctx where - value1_prop_id = #value1PropId# - - and value2_prop_id = #value2PropId# - - - and value3_prop_id = #value3PropId# - + value1_prop_id = #{value1PropId} + + and value2_prop_id = #{value2PropId} + + + and value3_prop_id = #{value3PropId} + - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/qname-common-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/qname-common-SqlMap.xml index ffa7cffb67..3f3b8c04eb 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/qname-common-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/qname-common-SqlMap.xml @@ -1,29 +1,20 @@ - + - - - - - - - - + - + - + @@ -34,15 +25,15 @@ - + - + - + @@ -52,20 +43,20 @@ insert into alf_namespace (version, uri) - values (#version#, #uri#) + values (#{version}, #{uri}) insert into alf_namespace (id, version, uri) - values (#id#, #version#, #uri#) + values (#{id}, #{version}, #{uri}) insert into alf_qname (version, ns_id, local_name) - values (#version#, #namespaceId#, #localName#) + values (#{version}, #{namespaceId}, #{localName}) insert into alf_qname (id, version, ns_id, local_name) - values (#id#, #version#, #namespaceId#, #localName#) + values (#{id}, #{version}, #{namespaceId}, #{localName}) @@ -90,13 +81,13 @@ uri = ? - + update alf_namespace set - uri = #uri# + uri = #{uri} where - id = #id# + id = #{id} - select * from alf_qname where - ns_id = #namespaceId# and - local_name = #localName# + ns_id = #{namespaceId} and + local_name = #{localName} - + update alf_qname set - ns_id = #namespaceId#, - local_name = #localName# + ns_id = #{namespaceId}, + local_name = #{localName} where - id = #id# + id = #{id} - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/query-test-common-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/query-test-common-SqlMap.xml index eeb4553a75..056fa2ee24 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/query-test-common-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/query-test-common-SqlMap.xml @@ -1,8 +1,5 @@ - - + - - - - - - - + - select count(*) from alf_mimetype - + where - mimetype_str = #mimetypeMatch# - mimetype_str like #mimetypeMatch# - - JUNKED + mimetype_str = #{mimetypeMatch} + mimetype_str like #{mimetypeMatch} + + JUNKED - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/query-usages-common-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/query-usages-common-SqlMap.xml index 1dbdddce29..c672f7fc2c 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/query-usages-common-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/query-usages-common-SqlMap.xml @@ -1,40 +1,33 @@ - - + - + - - - - - - - - select count(*) from alf_node n where n.type_qname_id in - #ids[]# + + #{item} + - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/solr-common-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/solr-common-SqlMap.xml index ceb5c0143b..154cfb3b4e 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/solr-common-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/solr-common-SqlMap.xml @@ -1,30 +1,26 @@ - + - + - - - - - - + + + + - + - - + + - select txn.id as id, txn.commit_time_ms as commit_time_ms, @@ -46,71 +42,86 @@ ) as deletes from alf_transaction txn - - - = #txnFromCommitTime#]]> - - - = #minTxnId#]]> - - + + + = #{txnFromCommitTime}]]> + + + = #{minTxnId}]]> + + order by txn.commit_time_ms ASC, txn.id ASC - select node.id as id, node.node_deleted as node_deleted, - node.transaction_id as txn_id + node.transaction_id as txn_id, + node.uuid as uuid, + store.protocol as protocol, + store.identifier as identifier from alf_transaction txn join alf_node node on (txn.id = node.transaction_id) - - join alf_store store on (store.id = node.store_id) - - - - - txn.id in #transactionIds[]# - - - = #fromNodeId#]]> - - - - - - store.protocol = #storeProtocol# - - - store.identifier = #storeIdentifier# - - - node.type_qname_id in #includeTypeIds[]# - - - node.type_qname_id not in #excludeTypeIds[]# - - - exists ( + + + txn.id in + + #{item} + + + + = #{fromNodeId}]]> + + + + + + and store.protocol = #{storeProtocol} + + + and store.identifier = #{storeIdentifier} + + + and node.type_qname_id in + + #{item} + + + + and node.type_qname_id not in + + #{item} + + + + and exists ( select * from alf_node_aspects aspects where aspects.node_id = node.id - and aspects.qname_id in #includeAspectIds[]# + and aspects.qname_id in + + #{item} + ) - - - not exists ( + + + and not exists ( select * from alf_node_aspects aspects where aspects.node_id = node.id - and aspects.qname_id in #excludeAspectIds[]# + and aspects.qname_id in + + #{item} + ) - - + + order by node.id ASC - \ No newline at end of file + + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/usage-common-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/usage-common-SqlMap.xml index 51898e3af3..c5942b8031 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/usage-common-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/usage-common-SqlMap.xml @@ -1,38 +1,30 @@ - + - + - - - - - - - + - + - + - + @@ -43,11 +35,11 @@ - + - + @@ -55,7 +47,7 @@ - + @@ -63,7 +55,7 @@ - + @@ -79,14 +71,14 @@ insert into alf_usage_delta (version, node_id, delta_size) values - (#version#, #nodeId#, #deltaSize#) + (#{version}, #{nodeId}, #{deltaSize}) insert into alf_usage_delta (id, version, node_id, delta_size) values - (#id#, #version#, #nodeId#, #deltaSize#) + (#{id}, #{version}, #{nodeId}, #{deltaSize}) @@ -109,7 +101,7 @@ - select distinct(node_id) from @@ -182,4 +174,4 @@ node_id = ? - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/audit-insert-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/audit-insert-SqlMap.xml index d0da280fbc..3c534e26ef 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/audit-insert-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/audit-insert-SqlMap.xml @@ -1,30 +1,19 @@ - + - + - + - - KEY_COLUMN:GENERATED_KEY - - - + + - - KEY_COLUMN:GENERATED_KEY - - - + + - - KEY_COLUMN:GENERATED_KEY - - - \ No newline at end of file + + \ No newline at end of file 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 417fa2ba1c..9f52956d70 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 @@ -1,37 +1,23 @@ - + - + - + - - KEY_COLUMN:GENERATED_KEY - - + - - KEY_COLUMN:GENERATED_KEY - - + - - KEY_COLUMN:GENERATED_KEY - - + - - KEY_COLUMN:GENERATED_KEY - - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/content-insert-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/content-insert-SqlMap.xml index a37e1d6072..c98e0c4b8b 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/content-insert-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/content-insert-SqlMap.xml @@ -1,37 +1,23 @@ - + - + - + - - KEY_COLUMN:GENERATED_KEY - - + - - KEY_COLUMN:GENERATED_KEY - - + - - KEY_COLUMN:GENERATED_KEY - - + - - KEY_COLUMN:GENERATED_KEY - - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/locale-insert-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/locale-insert-SqlMap.xml index df0b516cf3..3910d91c25 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/locale-insert-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/locale-insert-SqlMap.xml @@ -1,16 +1,11 @@ - - - + - + + + - - KEY_COLUMN:GENERATED_KEY - - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/locks-insert-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/locks-insert-SqlMap.xml index d559493c5b..a976c4060f 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/locks-insert-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/locks-insert-SqlMap.xml @@ -1,23 +1,15 @@ - + - + - + - - KEY_COLUMN:GENERATED_KEY - - + - - KEY_COLUMN:GENERATED_KEY - - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/node-insert-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/node-insert-SqlMap.xml index e209fcc8ab..1fced91780 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/node-insert-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/node-insert-SqlMap.xml @@ -1,51 +1,31 @@ - + - + - + - - KEY_COLUMN:GENERATED_KEY - - + - - KEY_COLUMN:GENERATED_KEY - - + - - KEY_COLUMN:GENERATED_KEY - - + - - KEY_COLUMN:GENERATED_KEY - - + - - KEY_COLUMN:GENERATED_KEY - - + - - KEY_COLUMN:GENERATED_KEY - - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/node-update-acl-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/node-update-acl-SqlMap.xml index f441ba13d5..cad03b9efe 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/node-update-acl-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/node-update-acl-SqlMap.xml @@ -1,27 +1,25 @@ - + - + - + update alf_child_assoc assoc - join alf_node child on (child.id = assoc.child_node_id and assoc.is_primary = #isPrimary#) + join alf_node child on (child.id = assoc.child_node_id and assoc.is_primary = #{isPrimary}) set - child.acl_id = #newSharedAclId# + child.acl_id = #{newSharedAclId} where - assoc.parent_node_id = #primaryParentNodeId# + assoc.parent_node_id = #{primaryParentNodeId} and ( child.acl_id is null - OR child.acl_id = #optionalOldSharedAclIdInAdditionToNull# + OR child.acl_id = #{optionalOldSharedAclIdInAdditionToNull} ) - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/permissions-insert-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/permissions-insert-SqlMap.xml index 766ad31ca9..cf50d9d712 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/permissions-insert-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/permissions-insert-SqlMap.xml @@ -1,65 +1,39 @@ - + - + - + - - KEY_COLUMN:GENERATED_KEY - - + - - KEY_COLUMN:GENERATED_KEY - - + - - KEY_COLUMN:GENERATED_KEY - - + - - KEY_COLUMN:GENERATED_KEY - - + - - KEY_COLUMN:GENERATED_KEY - - + - - KEY_COLUMN:GENERATED_KEY - - + - - KEY_COLUMN:GENERATED_KEY - - + - - KEY_COLUMN:GENERATED_KEY - - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/propval-insert-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/propval-insert-SqlMap.xml index ccf8667c9d..c3b5f99451 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/propval-insert-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/propval-insert-SqlMap.xml @@ -1,58 +1,35 @@ - + - + - + - - KEY_COLUMN:GENERATED_KEY - - + - - KEY_COLUMN:GENERATED_KEY - - + - - KEY_COLUMN:GENERATED_KEY - - + - - KEY_COLUMN:GENERATED_KEY - - + - - KEY_COLUMN:GENERATED_KEY - - + - - KEY_COLUMN:GENERATED_KEY - - + - - KEY_COLUMN:GENERATED_KEY - - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/qname-insert-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/qname-insert-SqlMap.xml index 223131fe67..be15718854 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/qname-insert-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/qname-insert-SqlMap.xml @@ -1,23 +1,15 @@ - + - + - + - - KEY_COLUMN:GENERATED_KEY - - + - - KEY_COLUMN:GENERATED_KEY - - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/usage-insert-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/usage-insert-SqlMap.xml index c9b23ee8ab..c6b75039cd 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/usage-insert-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/usage-insert-SqlMap.xml @@ -1,16 +1,11 @@ - + - + - + - - KEY_COLUMN:GENERATED_KEY - - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/activities-insert-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/activities-insert-SqlMap.xml index f7136dacba..a9614d1ac3 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/activities-insert-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/activities-insert-SqlMap.xml @@ -1,14 +1,12 @@ - + - + - + - + select nextVal('alf_activity_feed_control_seq') @@ -16,9 +14,9 @@ - + - + select nextVal('alf_activity_feed_seq') @@ -26,9 +24,9 @@ - + - + select nextVal('alf_activity_post_seq') @@ -36,4 +34,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/audit-insert-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/audit-insert-SqlMap.xml index 5f586d8734..60d48b5fb9 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/audit-insert-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/audit-insert-SqlMap.xml @@ -1,42 +1,37 @@ - + - + - + - + select nextVal('alf_audit_model_seq') - insert into alf_audit_model (id, content_data_id, content_crc) - values (#id#, #contentDataId#, #contentCrc#) + - - + + - + select nextVal('alf_audit_app_seq') - insert into alf_audit_app (id, version, app_name_id, audit_model_id, disabled_paths_id) - values (#id#, #version#, #applicationNameId#, #auditModelId#, #disabledPathsId#) + - - + + - + select nextVal('alf_audit_entry_seq') - insert into alf_audit_entry (id, audit_app_id, audit_user_id, audit_time, audit_values_id) - values (#id#, #auditApplicationId#, #auditUserId#, #auditTime#, #auditValuesId#) + - - \ No newline at end of file + + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/avm-insert-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/avm-insert-SqlMap.xml index 90b210c2d5..2071f25510 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/avm-insert-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/avm-insert-SqlMap.xml @@ -1,14 +1,12 @@ - + - + - + - + select nextVal('avm_stores_seq') @@ -18,7 +16,7 @@ - + select nextVal('avm_store_properties_seq') @@ -26,9 +24,9 @@ - + - + select nextVal('avm_nodes_seq') @@ -36,9 +34,9 @@ - + - + select nextVal('avm_version_roots_seq') @@ -46,4 +44,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/content-insert-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/content-insert-SqlMap.xml index ec6d23bd48..ace23d6ffc 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/content-insert-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/content-insert-SqlMap.xml @@ -1,53 +1,47 @@ - - - + + + - + - + select nextVal('alf_mimetype_seq') - insert into alf_mimetype (id, version, mimetype_str) - values (#id#, #version#, lower(#mimetype#)) + - + - + select nextVal('alf_encoding_seq') - insert into alf_encoding (id, version, encoding_str) - values (#id#, #version#, lower(#encoding#)) + - + - + select nextVal('alf_content_url_seq') - insert into alf_content_url (id, content_url, content_url_short, content_url_crc, content_size, orphan_time) - values (#id#, #contentUrl#, #contentUrlShort#, #contentUrlCrc#, #size#, #orphanTime#) + - + - + select nextVal('alf_content_data_seq') - insert into alf_content_data (id, version, content_url_id, content_mimetype_id, content_encoding_id, content_locale_id) - values (#id#, #version#, #contentUrlId#, #mimetypeId#, #encodingId#, #localeId#) + - + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/locale-insert-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/locale-insert-SqlMap.xml index ca925215ee..6798e30876 100755 --- a/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/locale-insert-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/locale-insert-SqlMap.xml @@ -1,18 +1,15 @@ - - - + - - + + + + select nextVal('alf_locale_seq') - insert into alf_locale (id, version, locale_str) - values (#id#, #version#, #localeStr#) + - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/locks-insert-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/locks-insert-SqlMap.xml index 80c12ad1da..089c6ac690 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/locks-insert-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/locks-insert-SqlMap.xml @@ -1,31 +1,27 @@ - + - + - + - + select nextVal('alf_lock_resource_seq') - insert into alf_lock_resource (id, version, qname_ns_id, qname_localname) - values (#id#, #version#, #qnameNamespaceId#, lower(#qnameLocalName#)) - + + - + - + select nextVal('alf_lock_seq') - insert into alf_lock (id, version, shared_resource_id, excl_resource_id, lock_token, start_time, expiry_time) - values (#id#, #version#, #sharedResourceId#, #exclusiveResourceId#, lower(#lockToken#), #startTime#, #expiryTime#) + - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/node-insert-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/node-insert-SqlMap.xml index 4a3c7790c0..e300164ce8 100755 --- a/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/node-insert-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/node-insert-SqlMap.xml @@ -1,58 +1,56 @@ - + - + - - + + select nextVal('alf_server_seq') - + - - + + select nextVal('alf_store_seq') - + - - + + select nextVal('alf_node_seq') - + - - + + select nextVal('alf_transaction_seq') - + - - + + select nextVal('alf_node_assoc_seq') - + - - + + select nextVal('alf_child_assoc_seq') - + - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/permissions-insert-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/permissions-insert-SqlMap.xml index f4ab268866..e012664e21 100755 --- a/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/permissions-insert-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/permissions-insert-SqlMap.xml @@ -1,13 +1,11 @@ - + - + - - + + select nextVal('alf_access_control_list_seq') @@ -15,8 +13,8 @@ - - + + select nextVal('alf_acl_member_seq') @@ -24,8 +22,8 @@ - - + + select nextVal('alf_acl_change_set_seq') @@ -33,8 +31,8 @@ - - + + select nextVal('alf_access_control_entry_seq') @@ -42,8 +40,8 @@ - - + + select nextVal('alf_ace_context_seq') @@ -51,8 +49,8 @@ - - + + select nextVal('alf_permission_seq') @@ -60,8 +58,8 @@ - - + + select nextVal('alf_authority_seq') @@ -69,8 +67,8 @@ - - + + select nextVal('alf_authority_alias_seq') @@ -78,4 +76,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/propval-insert-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/propval-insert-SqlMap.xml index c6ae2afa67..74736fc893 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/propval-insert-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/propval-insert-SqlMap.xml @@ -1,77 +1,57 @@ - + - + - - - + + select nextVal('alf_prop_class_seq') - - insert into alf_prop_class (id, java_class_name, java_class_name_short, java_class_name_crc) - values (#id#, #javaClassName#, #javaClassNameShort#, #javaClassNameCrc#) + - - - + + select nextVal('alf_prop_string_value_seq') - - insert into alf_prop_string_value (id, string_value, string_end_lower, string_crc) - values (#id#, #stringValue#, #stringEndLower#, #stringCrc#) - + - - - + + select nextVal('alf_prop_double_value_seq') - - insert into alf_prop_double_value (id, double_value) - values (#id#, #doubleValue#) - + - - + select nextVal('alf_prop_serializable_value_seq') - - insert into alf_prop_serializable_value (id, serializable_value) - values (?, ?) - + - - - + + select nextVal('alf_prop_value_seq') - - insert into alf_prop_value (id, actual_type_id, persisted_type, long_value) - values (#id#, #actualTypeId#, #persistedType#, #longValue#) - + - + select nextVal('alf_prop_root_seq') - - + + select nextVal('alf_prop_unique_ctx_seq') - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/qname-insert-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/qname-insert-SqlMap.xml index f14460eb94..4258c18afd 100755 --- a/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/qname-insert-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/qname-insert-SqlMap.xml @@ -1,21 +1,19 @@ - + - + - - + + select nextVal('alf_namespace_seq') - + - - + + select nextVal('alf_qname_seq') @@ -23,4 +21,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/usage-insert-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/usage-insert-SqlMap.xml index e07a958d7e..836796178c 100755 --- a/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/usage-insert-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/usage-insert-SqlMap.xml @@ -1,17 +1,15 @@ - + - + - - + + select nextVal('alf_usage_delta_seq') - + - \ No newline at end of file + \ No newline at end of file diff --git a/config/alfresco/ibatis/repo-SqlMapConfig.xml b/config/alfresco/ibatis/repo-SqlMapConfig.xml new file mode 100644 index 0000000000..1d0187cad1 --- /dev/null +++ b/config/alfresco/ibatis/repo-SqlMapConfig.xml @@ -0,0 +1,163 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/source/java/org/alfresco/repo/admin/patch/impl/MigrateAttrAVMLocksPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/MigrateAttrAVMLocksPatch.java index dadca1baf9..890c36b16e 100644 --- a/source/java/org/alfresco/repo/admin/patch/impl/MigrateAttrAVMLocksPatch.java +++ b/source/java/org/alfresco/repo/admin/patch/impl/MigrateAttrAVMLocksPatch.java @@ -28,10 +28,10 @@ import org.alfresco.service.cmr.attributes.AttributeService; import org.alfresco.wcm.util.WCMUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.ibatis.session.ResultContext; +import org.apache.ibatis.session.ResultHandler; import org.springframework.extensions.surf.util.I18NUtil; -import com.ibatis.sqlmap.client.event.RowHandler; - /** * Migrate AVM lock attributes (from 'alf_*attribute*' to 'alf_prop_*') * @@ -62,7 +62,7 @@ public class MigrateAttrAVMLocksPatch extends AbstractPatch { long startTime = System.currentTimeMillis(); - AVMLockRowHandler handler = new AVMLockRowHandler(); + AVMLockResultHandler handler = new AVMLockResultHandler(); patchDAO.migrateOldAttrAVMLocks(handler); if (handler.total > 0) @@ -79,17 +79,17 @@ public class MigrateAttrAVMLocksPatch extends AbstractPatch /** * Row handler for migrating AVM Locks */ - private class AVMLockRowHandler implements RowHandler + private class AVMLockResultHandler implements ResultHandler { private int total = 0; - private AVMLockRowHandler() + private AVMLockResultHandler() { } @SuppressWarnings("unchecked") - public void handleRow(Object valueObject) + public void handleResult(ResultContext context) { - Map result = (Map)valueObject; + Map result = (Map)context.getResultObject(); String wpStoreId = (String)result.get("wpStoreId"); String path = (String)result.get("relPath"); diff --git a/source/java/org/alfresco/repo/admin/patch/impl/MigrateAttrChainingURSPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/MigrateAttrChainingURSPatch.java index 28a97ded0e..fb7f7cb8f0 100644 --- a/source/java/org/alfresco/repo/admin/patch/impl/MigrateAttrChainingURSPatch.java +++ b/source/java/org/alfresco/repo/admin/patch/impl/MigrateAttrChainingURSPatch.java @@ -26,10 +26,10 @@ import org.alfresco.repo.security.sync.ChainingUserRegistrySynchronizer; import org.alfresco.service.cmr.attributes.AttributeService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.ibatis.session.ResultContext; +import org.apache.ibatis.session.ResultHandler; import org.springframework.extensions.surf.util.I18NUtil; -import com.ibatis.sqlmap.client.event.RowHandler; - /** * Migrate Chaining User Registry Synchronizer attributes (from 'alf_*attribute*' to 'alf_prop_*') * @@ -60,7 +60,7 @@ public class MigrateAttrChainingURSPatch extends AbstractPatch { long startTime = System.currentTimeMillis(); - ChainingURSRowHandler handler = new ChainingURSRowHandler(); + ChainingURSResultHandler handler = new ChainingURSResultHandler(); patchDAO.migrateOldAttrChainingURS(handler); if (handler.total > 0) @@ -74,17 +74,17 @@ public class MigrateAttrChainingURSPatch extends AbstractPatch return msg; } - private class ChainingURSRowHandler implements RowHandler + private class ChainingURSResultHandler implements ResultHandler { private int total = 0; - private ChainingURSRowHandler() + private ChainingURSResultHandler() { } @SuppressWarnings("unchecked") - public void handleRow(Object valueObject) + public void handleResult(ResultContext context) { - Map result = (Map)valueObject; + Map result = (Map)context.getResultObject(); String label = (String)result.get("label"); String zoneId = (String)result.get("zoneId"); diff --git a/source/java/org/alfresco/repo/admin/patch/impl/MigrateAttrPropBackedBeanPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/MigrateAttrPropBackedBeanPatch.java index 558dd486c3..88303a2fc2 100644 --- a/source/java/org/alfresco/repo/admin/patch/impl/MigrateAttrPropBackedBeanPatch.java +++ b/source/java/org/alfresco/repo/admin/patch/impl/MigrateAttrPropBackedBeanPatch.java @@ -27,10 +27,10 @@ import org.alfresco.repo.domain.patch.PatchDAO; import org.alfresco.service.cmr.attributes.AttributeService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.ibatis.session.ResultContext; +import org.apache.ibatis.session.ResultHandler; import org.springframework.extensions.surf.util.I18NUtil; -import com.ibatis.sqlmap.client.event.RowHandler; - /** * Migrate Property-Backed Bean attributes (from 'alf_*attribute*' to 'alf_prop_*') * @@ -63,7 +63,7 @@ public class MigrateAttrPropBackedBeanPatch extends AbstractPatch { long startTime = System.currentTimeMillis(); - PBBRowHandler handler = new PBBRowHandler(); + PBBesultHandler handler = new PBBesultHandler(); patchDAO.migrateOldAttrPropertyBackedBeans(handler); handler.setComponent(handler.currentComponentName, handler.attributeMap); // set last component attribute (if any) @@ -78,7 +78,7 @@ public class MigrateAttrPropBackedBeanPatch extends AbstractPatch return msg; } - private class PBBRowHandler implements RowHandler + private class PBBesultHandler implements ResultHandler { private int total = 0; private int totalProps = 0; @@ -86,13 +86,13 @@ public class MigrateAttrPropBackedBeanPatch extends AbstractPatch private Map attributeMap = new HashMap(10); private String currentComponentName = ""; - private PBBRowHandler() + private PBBesultHandler() { } @SuppressWarnings("unchecked") - public void handleRow(Object valueObject) + public void handleResult(ResultContext context) { - Map result = (Map)valueObject; + Map result = (Map)context.getResultObject(); String componentName = (String)result.get("componentName"); String propName = (String)result.get("propName"); diff --git a/source/java/org/alfresco/repo/admin/patch/impl/MigrateAttrTenantsPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/MigrateAttrTenantsPatch.java index 5746684a50..6a2adc04a9 100644 --- a/source/java/org/alfresco/repo/admin/patch/impl/MigrateAttrTenantsPatch.java +++ b/source/java/org/alfresco/repo/admin/patch/impl/MigrateAttrTenantsPatch.java @@ -28,10 +28,10 @@ import org.alfresco.repo.tenant.MultiTAdminServiceImpl; import org.alfresco.service.cmr.attributes.AttributeService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.ibatis.session.ResultContext; +import org.apache.ibatis.session.ResultHandler; import org.springframework.extensions.surf.util.I18NUtil; -import com.ibatis.sqlmap.client.event.RowHandler; - /** * Migrate Tenant attributes (from 'alf_*attribute*' to 'alf_prop_*') * @@ -62,7 +62,7 @@ public class MigrateAttrTenantsPatch extends AbstractPatch { long startTime = System.currentTimeMillis(); - TenantRowHandler handler = new TenantRowHandler(); + TenantResultHandler handler = new TenantResultHandler(); patchDAO.migrateOldAttrTenants(handler); if (handler.total > 0) @@ -79,17 +79,17 @@ public class MigrateAttrTenantsPatch extends AbstractPatch /** * Row handler for migrating tenants */ - private class TenantRowHandler implements RowHandler + private class TenantResultHandler implements ResultHandler { private int total = 0; - private TenantRowHandler() + private TenantResultHandler() { } @SuppressWarnings("unchecked") - public void handleRow(Object valueObject) + public void handleResult(ResultContext context) { - Map result = (Map)valueObject; + Map result = (Map)context.getResultObject(); String tenantDomain = (String)result.get("tenantDomain"); Boolean isEnabled = (Boolean)result.get("isEnabled"); diff --git a/source/java/org/alfresco/repo/domain/activities/ibatis/ActivitiesSqlSessionDaoSupport.java b/source/java/org/alfresco/repo/domain/activities/ibatis/ActivitiesDAOImpl.java similarity index 78% rename from source/java/org/alfresco/repo/domain/activities/ibatis/ActivitiesSqlSessionDaoSupport.java rename to source/java/org/alfresco/repo/domain/activities/ibatis/ActivitiesDAOImpl.java index dd040716e0..647c362513 100644 --- a/source/java/org/alfresco/repo/domain/activities/ibatis/ActivitiesSqlSessionDaoSupport.java +++ b/source/java/org/alfresco/repo/domain/activities/ibatis/ActivitiesDAOImpl.java @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2005-2010 Alfresco Software Limited. * * This file is part of Alfresco @@ -14,34 +14,41 @@ * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.domain.activities.ibatis; - -import java.sql.SQLException; - -import org.alfresco.repo.domain.activities.ActivitiesDAO; -import org.mybatis.spring.support.SqlSessionDaoSupport; - -public class ActivitiesSqlSessionDaoSupport extends SqlSessionDaoSupport implements ActivitiesDAO -{ - public void startTransaction() throws SQLException - { - // NOOP - } - - public void commitTransaction() throws SQLException - { - // NOOP - } - - public void rollbackTransaction() throws SQLException - { - // NOOP - } - - public void endTransaction() throws SQLException - { - // NOOP - } -} + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.domain.activities.ibatis; + +import java.sql.SQLException; + +import org.alfresco.repo.domain.activities.ActivitiesDAO; +import org.mybatis.spring.SqlSessionTemplate; + +public class ActivitiesDAOImpl implements ActivitiesDAO +{ + protected SqlSessionTemplate template; + + public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) + { + this.template = sqlSessionTemplate; + } + + public void startTransaction() throws SQLException + { + // NOOP + } + + public void commitTransaction() throws SQLException + { + // NOOP + } + + public void rollbackTransaction() throws SQLException + { + // NOOP + } + + public void endTransaction() throws SQLException + { + // NOOP + } +} diff --git a/source/java/org/alfresco/repo/domain/activities/ibatis/ActivityFeedDAOImpl.java b/source/java/org/alfresco/repo/domain/activities/ibatis/ActivityFeedDAOImpl.java index e2e5166292..4228f2f49f 100644 --- a/source/java/org/alfresco/repo/domain/activities/ibatis/ActivityFeedDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/activities/ibatis/ActivityFeedDAOImpl.java @@ -1,173 +1,173 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.domain.activities.ibatis; - -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.domain.activities.ActivityFeedDAO; -import org.alfresco.repo.domain.activities.ActivityFeedEntity; -import org.alfresco.repo.domain.activities.ActivityFeedQueryEntity; -import org.apache.ibatis.session.RowBounds; - -public class ActivityFeedDAOImpl extends ActivitiesSqlSessionDaoSupport implements ActivityFeedDAO -{ - public long insertFeedEntry(ActivityFeedEntity activityFeed) throws SQLException - { - getSqlSession().insert("alfresco.activities.insert.insert_activity_feed", activityFeed); - Long id = activityFeed.getId(); - return (id != null ? id : -1); - } - - public int deleteFeedEntries(Date keepDate) throws SQLException - { - return getSqlSession().delete("alfresco.activities.delete_activity_feed_entries_older_than_date", keepDate); - } - - public int deleteSiteFeedEntries(String siteId) throws SQLException - { - ActivityFeedEntity params = new ActivityFeedEntity(); - params.setSiteNetwork(siteId); - - return getSqlSession().delete("alfresco.activities.delete_activity_feed_for_site_entries", params); - } - - public int deleteSiteFeedEntries(String siteId, String format, Date keepDate) throws SQLException - { - ActivityFeedEntity params = new ActivityFeedEntity(); - params.setSiteNetwork(siteId); - params.setActivitySummaryFormat(format); - params.setPostDate(keepDate); - - return getSqlSession().delete("alfresco.activities.delete_activity_feed_for_site_entries_older_than_date", params); - } - - - public int deleteUserFeedEntries(String feedUserId, String format, Date keepDate) throws SQLException - { - ActivityFeedEntity params = new ActivityFeedEntity(); - params.setFeedUserId(feedUserId); - params.setActivitySummaryFormat(format); - params.setPostDate(keepDate); - - return getSqlSession().delete("alfresco.activities.delete_activity_feed_for_feeduser_entries_older_than_date", params); - } - - public int deleteUserFeedEntries(String feedUserId) throws SQLException - { - ActivityFeedEntity params = new ActivityFeedEntity(); - params.setFeedUserId(feedUserId); - - return getSqlSession().delete("alfresco.activities.delete_activity_feed_for_feeduser_entries", params); - } - - @SuppressWarnings("unchecked") - public List selectFeedsToClean(int maxFeedSize) throws SQLException - { - return (List)getSqlSession().selectList("alfresco.activities.select_activity_feed_greater_than_max", maxFeedSize); - } - - @SuppressWarnings("unchecked") - public List selectUserFeedEntries(String feedUserId, String format, String siteId, boolean excludeThisUser, boolean excludeOtherUsers, long minFeedId, int maxFeedSize) throws SQLException - { - ActivityFeedQueryEntity params = new ActivityFeedQueryEntity(); - params.setFeedUserId(feedUserId); - params.setActivitySummaryFormat(format); - - if (minFeedId > -1) - { - params.setMinId(minFeedId); - } - - int rowLimit = maxFeedSize < 0 ? RowBounds.NO_ROW_LIMIT : maxFeedSize; - RowBounds rowBounds = new RowBounds(RowBounds.NO_ROW_OFFSET, rowLimit); - - if (siteId != null) - { - // given site - params.setSiteNetwork(siteId); - - if (excludeThisUser && excludeOtherUsers) - { - // effectively NOOP - return empty feed - return new ArrayList(0); - } - if ((!excludeThisUser) && (!excludeOtherUsers)) - { - // no excludes => everyone => where feed user is me - return (List)getSqlSession().selectList("alfresco.activities.select_activity_feed_for_feeduser_and_site", params, rowBounds); - } - else if ((excludeThisUser) && (!excludeOtherUsers)) - { - // exclude feed user => others => where feed user is me and post user is not me - return (List)getSqlSession().selectList("alfresco.activities.select_activity_feed_for_feeduser_others_and_site", params, rowBounds); - } - else if ((excludeOtherUsers) && (!excludeThisUser)) - { - // exclude others => me => where feed user is me and post user is me - return (List)getSqlSession().selectList("alfresco.activities.select_activity_feed_for_feeduser_me_and_site", params, rowBounds); - } - } - else - { - // all sites - - if (excludeThisUser && excludeOtherUsers) - { - // effectively NOOP - return empty feed - return new ArrayList(0); - } - if (!excludeThisUser && !excludeOtherUsers) - { - // no excludes => everyone => where feed user is me - return (List)getSqlSession().selectList("alfresco.activities.select_activity_feed_for_feeduser", params, rowBounds); - } - else if (excludeThisUser) - { - // exclude feed user => others => where feed user is me and post user is not me - return (List)getSqlSession().selectList("alfresco.activities.select_activity_feed_for_feeduser_others", params, rowBounds); - } - else if (excludeOtherUsers) - { - // exclude others => me => where feed user is me and post user is me - return (List)getSqlSession().selectList("alfresco.activities.select_activity_feed_for_feeduser_me", params, rowBounds); - } - } - - // belts-and-braces - throw new AlfrescoRuntimeException("Unexpected: invalid arguments"); - } - - @SuppressWarnings("unchecked") - public List selectSiteFeedEntries(String siteId, String format, int maxFeedSize) throws SQLException - { - ActivityFeedQueryEntity params = new ActivityFeedQueryEntity(); - params.setSiteNetwork(siteId); - params.setActivitySummaryFormat(format); - - int rowLimit = maxFeedSize < 0 ? RowBounds.NO_ROW_LIMIT : maxFeedSize; - RowBounds rowBounds = new RowBounds(RowBounds.NO_ROW_OFFSET, rowLimit); - - // for given site - return (List)getSqlSession().selectList("alfresco.activities.select_activity_feed_for_site", params, rowBounds); - } -} +/* + * Copyright (C) 2005-2010 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.domain.activities.ibatis; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.repo.domain.activities.ActivityFeedDAO; +import org.alfresco.repo.domain.activities.ActivityFeedEntity; +import org.alfresco.repo.domain.activities.ActivityFeedQueryEntity; +import org.apache.ibatis.session.RowBounds; + +public class ActivityFeedDAOImpl extends ActivitiesDAOImpl implements ActivityFeedDAO +{ + public long insertFeedEntry(ActivityFeedEntity activityFeed) throws SQLException + { + template.insert("alfresco.activities.insert.insert_activity_feed", activityFeed); + Long id = activityFeed.getId(); + return (id != null ? id : -1); + } + + public int deleteFeedEntries(Date keepDate) throws SQLException + { + return template.delete("alfresco.activities.delete_activity_feed_entries_older_than_date", keepDate); + } + + public int deleteSiteFeedEntries(String siteId) throws SQLException + { + ActivityFeedEntity params = new ActivityFeedEntity(); + params.setSiteNetwork(siteId); + + return template.delete("alfresco.activities.delete_activity_feed_for_site_entries", params); + } + + public int deleteSiteFeedEntries(String siteId, String format, Date keepDate) throws SQLException + { + ActivityFeedEntity params = new ActivityFeedEntity(); + params.setSiteNetwork(siteId); + params.setActivitySummaryFormat(format); + params.setPostDate(keepDate); + + return template.delete("alfresco.activities.delete_activity_feed_for_site_entries_older_than_date", params); + } + + + public int deleteUserFeedEntries(String feedUserId, String format, Date keepDate) throws SQLException + { + ActivityFeedEntity params = new ActivityFeedEntity(); + params.setFeedUserId(feedUserId); + params.setActivitySummaryFormat(format); + params.setPostDate(keepDate); + + return template.delete("alfresco.activities.delete_activity_feed_for_feeduser_entries_older_than_date", params); + } + + public int deleteUserFeedEntries(String feedUserId) throws SQLException + { + ActivityFeedEntity params = new ActivityFeedEntity(); + params.setFeedUserId(feedUserId); + + return template.delete("alfresco.activities.delete_activity_feed_for_feeduser_entries", params); + } + + @SuppressWarnings("unchecked") + public List selectFeedsToClean(int maxFeedSize) throws SQLException + { + return (List)template.selectList("alfresco.activities.select_activity_feed_greater_than_max", maxFeedSize); + } + + @SuppressWarnings("unchecked") + public List selectUserFeedEntries(String feedUserId, String format, String siteId, boolean excludeThisUser, boolean excludeOtherUsers, long minFeedId, int maxFeedSize) throws SQLException + { + ActivityFeedQueryEntity params = new ActivityFeedQueryEntity(); + params.setFeedUserId(feedUserId); + params.setActivitySummaryFormat(format); + + if (minFeedId > -1) + { + params.setMinId(minFeedId); + } + + int rowLimit = maxFeedSize < 0 ? RowBounds.NO_ROW_LIMIT : maxFeedSize; + RowBounds rowBounds = new RowBounds(RowBounds.NO_ROW_OFFSET, rowLimit); + + if (siteId != null) + { + // given site + params.setSiteNetwork(siteId); + + if (excludeThisUser && excludeOtherUsers) + { + // effectively NOOP - return empty feed + return new ArrayList(0); + } + if ((!excludeThisUser) && (!excludeOtherUsers)) + { + // no excludes => everyone => where feed user is me + return (List)template.selectList("alfresco.activities.select_activity_feed_for_feeduser_and_site", params, rowBounds); + } + else if ((excludeThisUser) && (!excludeOtherUsers)) + { + // exclude feed user => others => where feed user is me and post user is not me + return (List)template.selectList("alfresco.activities.select_activity_feed_for_feeduser_others_and_site", params, rowBounds); + } + else if ((excludeOtherUsers) && (!excludeThisUser)) + { + // exclude others => me => where feed user is me and post user is me + return (List)template.selectList("alfresco.activities.select_activity_feed_for_feeduser_me_and_site", params, rowBounds); + } + } + else + { + // all sites + + if (excludeThisUser && excludeOtherUsers) + { + // effectively NOOP - return empty feed + return new ArrayList(0); + } + if (!excludeThisUser && !excludeOtherUsers) + { + // no excludes => everyone => where feed user is me + return (List)template.selectList("alfresco.activities.select_activity_feed_for_feeduser", params, rowBounds); + } + else if (excludeThisUser) + { + // exclude feed user => others => where feed user is me and post user is not me + return (List)template.selectList("alfresco.activities.select_activity_feed_for_feeduser_others", params, rowBounds); + } + else if (excludeOtherUsers) + { + // exclude others => me => where feed user is me and post user is me + return (List)template.selectList("alfresco.activities.select_activity_feed_for_feeduser_me", params, rowBounds); + } + } + + // belts-and-braces + throw new AlfrescoRuntimeException("Unexpected: invalid arguments"); + } + + @SuppressWarnings("unchecked") + public List selectSiteFeedEntries(String siteId, String format, int maxFeedSize) throws SQLException + { + ActivityFeedQueryEntity params = new ActivityFeedQueryEntity(); + params.setSiteNetwork(siteId); + params.setActivitySummaryFormat(format); + + int rowLimit = maxFeedSize < 0 ? RowBounds.NO_ROW_LIMIT : maxFeedSize; + RowBounds rowBounds = new RowBounds(RowBounds.NO_ROW_OFFSET, rowLimit); + + // for given site + return (List)template.selectList("alfresco.activities.select_activity_feed_for_site", params, rowBounds); + } +} diff --git a/source/java/org/alfresco/repo/domain/activities/ibatis/ActivityPostDAOImpl.java b/source/java/org/alfresco/repo/domain/activities/ibatis/ActivityPostDAOImpl.java index dba2f68702..e7f8b46ed4 100644 --- a/source/java/org/alfresco/repo/domain/activities/ibatis/ActivityPostDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/activities/ibatis/ActivityPostDAOImpl.java @@ -1,103 +1,103 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.domain.activities.ibatis; - -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import org.alfresco.repo.domain.activities.ActivityPostDAO; -import org.alfresco.repo.domain.activities.ActivityPostEntity; - -public class ActivityPostDAOImpl extends ActivitiesSqlSessionDaoSupport implements ActivityPostDAO -{ - @SuppressWarnings("unchecked") - public List selectPosts(ActivityPostEntity activityPost) throws SQLException - { - if ((activityPost.getJobTaskNode() != -1) && - (activityPost.getMinId() != -1) && - (activityPost.getMaxId() != -1) && - (activityPost.getStatus() != null)) - { - return (List)getSqlSession().selectList("alfresco.activities.select_activity_posts", activityPost); - } - else if (activityPost.getStatus() != null) - { - return (List)getSqlSession().selectList("alfresco.activities.select_activity_posts_by_status_only", activityPost); - } - else - { - return new ArrayList(0); - } - } - - public Long getMaxActivitySeq() throws SQLException - { - return (Long)getSqlSession().selectOne("alfresco.activities.select_activity_post_max_seq"); - } - - public Long getMinActivitySeq() throws SQLException - { - return (Long)getSqlSession().selectOne("alfresco.activities.select_activity_post_min_seq"); - } - - public Integer getMaxNodeHash() throws SQLException - { - return (Integer)getSqlSession().selectOne("alfresco.activities.select_activity_post_max_jobtasknode"); - } - - public int updatePost(long id, String siteNetwork, String activityData, ActivityPostEntity.STATUS status) throws SQLException - { - ActivityPostEntity post = new ActivityPostEntity(); - post.setId(id); - post.setSiteNetwork(siteNetwork); - post.setActivityData(activityData); - post.setStatus(status.toString()); - post.setLastModified(new Date()); - - return getSqlSession().update("alfresco.activities.update_activity_post_data", post); - } - - public int updatePostStatus(long id, ActivityPostEntity.STATUS status) throws SQLException - { - ActivityPostEntity post = new ActivityPostEntity(); - post.setId(id); - post.setStatus(status.toString()); - post.setLastModified(new Date()); - - return getSqlSession().update("alfresco.activities.update_activity_post_status", post); - } - - public int deletePosts(Date keepDate, ActivityPostEntity.STATUS status) throws SQLException - { - ActivityPostEntity params = new ActivityPostEntity(); - params.setPostDate(keepDate); - params.setStatus(status.toString()); - - return getSqlSession().delete("alfresco.activities.delete_activity_posts_older_than_date", params); - } - - public long insertPost(ActivityPostEntity activityPost) throws SQLException - { - getSqlSession().insert("alfresco.activities.insert.insert_activity_post", activityPost); - Long id = activityPost.getId(); - return (id != null ? id : -1); - } -} +/* + * Copyright (C) 2005-2010 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.domain.activities.ibatis; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.alfresco.repo.domain.activities.ActivityPostDAO; +import org.alfresco.repo.domain.activities.ActivityPostEntity; + +public class ActivityPostDAOImpl extends ActivitiesDAOImpl implements ActivityPostDAO +{ + @SuppressWarnings("unchecked") + public List selectPosts(ActivityPostEntity activityPost) throws SQLException + { + if ((activityPost.getJobTaskNode() != -1) && + (activityPost.getMinId() != -1) && + (activityPost.getMaxId() != -1) && + (activityPost.getStatus() != null)) + { + return (List)template.selectList("alfresco.activities.select_activity_posts", activityPost); + } + else if (activityPost.getStatus() != null) + { + return (List)template.selectList("alfresco.activities.select_activity_posts_by_status_only", activityPost); + } + else + { + return new ArrayList(0); + } + } + + public Long getMaxActivitySeq() throws SQLException + { + return (Long)template.selectOne("alfresco.activities.select_activity_post_max_seq"); + } + + public Long getMinActivitySeq() throws SQLException + { + return (Long)template.selectOne("alfresco.activities.select_activity_post_min_seq"); + } + + public Integer getMaxNodeHash() throws SQLException + { + return (Integer)template.selectOne("alfresco.activities.select_activity_post_max_jobtasknode"); + } + + public int updatePost(long id, String siteNetwork, String activityData, ActivityPostEntity.STATUS status) throws SQLException + { + ActivityPostEntity post = new ActivityPostEntity(); + post.setId(id); + post.setSiteNetwork(siteNetwork); + post.setActivityData(activityData); + post.setStatus(status.toString()); + post.setLastModified(new Date()); + + return template.update("alfresco.activities.update_activity_post_data", post); + } + + public int updatePostStatus(long id, ActivityPostEntity.STATUS status) throws SQLException + { + ActivityPostEntity post = new ActivityPostEntity(); + post.setId(id); + post.setStatus(status.toString()); + post.setLastModified(new Date()); + + return template.update("alfresco.activities.update_activity_post_status", post); + } + + public int deletePosts(Date keepDate, ActivityPostEntity.STATUS status) throws SQLException + { + ActivityPostEntity params = new ActivityPostEntity(); + params.setPostDate(keepDate); + params.setStatus(status.toString()); + + return template.delete("alfresco.activities.delete_activity_posts_older_than_date", params); + } + + public long insertPost(ActivityPostEntity activityPost) throws SQLException + { + template.insert("alfresco.activities.insert.insert_activity_post", activityPost); + Long id = activityPost.getId(); + return (id != null ? id : -1); + } +} diff --git a/source/java/org/alfresco/repo/domain/activities/ibatis/FeedControlDAOImpl.java b/source/java/org/alfresco/repo/domain/activities/ibatis/FeedControlDAOImpl.java index 8b77a0e51d..a6f6bd2a07 100644 --- a/source/java/org/alfresco/repo/domain/activities/ibatis/FeedControlDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/activities/ibatis/FeedControlDAOImpl.java @@ -1,54 +1,54 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.domain.activities.ibatis; - -import java.sql.SQLException; -import java.util.List; - -import org.alfresco.repo.domain.activities.FeedControlDAO; -import org.alfresco.repo.domain.activities.FeedControlEntity; - -public class FeedControlDAOImpl extends ActivitiesSqlSessionDaoSupport implements FeedControlDAO -{ - public long insertFeedControl(FeedControlEntity activityFeedControl) throws SQLException - { - getSqlSession().insert("alfresco.activities.insert.insert_activity_feedcontrol", activityFeedControl); - Long id = activityFeedControl.getId(); - return (id != null ? id : -1); - } - - public int deleteFeedControl(FeedControlEntity activityFeedControl) throws SQLException - { - return getSqlSession().delete("alfresco.activities.delete_activity_feedcontrol", activityFeedControl); - } - - @SuppressWarnings("unchecked") - public List selectFeedControls(String feedUserId) throws SQLException - { - FeedControlEntity params = new FeedControlEntity(feedUserId); - - return (List)getSqlSession().selectList("alfresco.activities.select_activity_feedcontrols_for_user", params); - } - - public long selectFeedControl(FeedControlEntity activityFeedControl) throws SQLException - { - Long id = (Long)getSqlSession().selectOne("alfresco.activities.select_activity_feedcontrol", activityFeedControl); - return (id != null ? id : -1); - } -} +/* + * Copyright (C) 2005-2010 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.domain.activities.ibatis; + +import java.sql.SQLException; +import java.util.List; + +import org.alfresco.repo.domain.activities.FeedControlDAO; +import org.alfresco.repo.domain.activities.FeedControlEntity; + +public class FeedControlDAOImpl extends ActivitiesDAOImpl implements FeedControlDAO +{ + public long insertFeedControl(FeedControlEntity activityFeedControl) throws SQLException + { + template.insert("alfresco.activities.insert.insert_activity_feedcontrol", activityFeedControl); + Long id = activityFeedControl.getId(); + return (id != null ? id : -1); + } + + public int deleteFeedControl(FeedControlEntity activityFeedControl) throws SQLException + { + return template.delete("alfresco.activities.delete_activity_feedcontrol", activityFeedControl); + } + + @SuppressWarnings("unchecked") + public List selectFeedControls(String feedUserId) throws SQLException + { + FeedControlEntity params = new FeedControlEntity(feedUserId); + + return (List)template.selectList("alfresco.activities.select_activity_feedcontrols_for_user", params); + } + + public long selectFeedControl(FeedControlEntity activityFeedControl) throws SQLException + { + Long id = (Long)template.selectOne("alfresco.activities.select_activity_feedcontrol", activityFeedControl); + return (id != null ? id : -1); + } +} diff --git a/source/java/org/alfresco/repo/domain/audit/ibatis/AuditDAOImpl.java b/source/java/org/alfresco/repo/domain/audit/ibatis/AuditDAOImpl.java index 8d06130051..a9247e620b 100644 --- a/source/java/org/alfresco/repo/domain/audit/ibatis/AuditDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/audit/ibatis/AuditDAOImpl.java @@ -24,7 +24,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.alfresco.ibatis.RollupRowHandler; +import org.alfresco.ibatis.RollupResultHandler; import org.alfresco.repo.domain.audit.AbstractAuditDAOImpl; import org.alfresco.repo.domain.audit.AuditApplicationEntity; import org.alfresco.repo.domain.audit.AuditDeleteParameters; @@ -34,9 +34,11 @@ import org.alfresco.repo.domain.audit.AuditQueryParameters; import org.alfresco.repo.domain.audit.AuditQueryResult; import org.alfresco.repo.domain.propval.PropertyValueDAO.PropertyFinderCallback; import org.alfresco.util.Pair; -import org.springframework.orm.ibatis.SqlMapClientTemplate; - -import com.ibatis.sqlmap.client.event.RowHandler; +import org.apache.ibatis.session.ResultContext; +import org.apache.ibatis.session.ResultHandler; +import org.apache.ibatis.session.RowBounds; +import org.mybatis.spring.SqlSessionTemplate; +import org.springframework.dao.ConcurrencyFailureException; /** * iBatis-specific implementation of the DAO for alf_audit_XXX tables. @@ -47,26 +49,26 @@ import com.ibatis.sqlmap.client.event.RowHandler; public class AuditDAOImpl extends AbstractAuditDAOImpl { private static final String SELECT_MODEL_BY_CRC = "alfresco.audit.select_AuditModelByCrc"; - private static final String INSERT_MODEL = "alfresco.audit.insert_AuditModel"; + private static final String INSERT_MODEL = "alfresco.audit.insert.insert_AuditModel"; private static final String SELECT_APPLICATION_BY_ID = "alfresco.audit.select_AuditApplicationById"; private static final String SELECT_APPLICATION_BY_NAME_ID = "alfresco.audit.select_AuditApplicationByNameId"; - private static final String INSERT_APPLICATION = "alfresco.audit.insert_AuditApplication"; + private static final String INSERT_APPLICATION = "alfresco.audit.insert.insert_AuditApplication"; private static final String UPDATE_APPLICATION = "alfresco.audit.update_AuditApplication"; private static final String DELETE_ENTRIES = "alfresco.audit.delete_AuditEntries"; - private static final String INSERT_ENTRY = "alfresco.audit.insert_AuditEntry"; + private static final String INSERT_ENTRY = "alfresco.audit.insert.insert_AuditEntry"; @SuppressWarnings("unused") private static final String SELECT_ENTRIES_SIMPLE = "alfresco.audit.select_AuditEntriesSimple"; private static final String SELECT_ENTRIES_WITH_VALUES = "alfresco.audit.select_AuditEntriesWithValues"; private static final String SELECT_ENTRIES_WITHOUT_VALUES = "alfresco.audit.select_AuditEntriesWithoutValues"; - private SqlMapClientTemplate template; - - public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) + private SqlSessionTemplate template; + + public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) { - this.template = sqlMapClientTemplate; + this.template = sqlSessionTemplate; } @Override @@ -74,7 +76,7 @@ public class AuditDAOImpl extends AbstractAuditDAOImpl { AuditModelEntity entity = new AuditModelEntity(); entity.setContentCrc(crc); - entity = (AuditModelEntity) template.queryForObject( + entity = (AuditModelEntity) template.selectOne( SELECT_MODEL_BY_CRC, entity); // Done @@ -87,8 +89,7 @@ public class AuditDAOImpl extends AbstractAuditDAOImpl AuditModelEntity entity = new AuditModelEntity(); entity.setContentDataId(contentDataId); entity.setContentCrc(crc); - Long id = (Long) template.insert(INSERT_MODEL, entity); - entity.setId(id); + template.insert(INSERT_MODEL, entity); return entity; } @@ -97,7 +98,7 @@ public class AuditDAOImpl extends AbstractAuditDAOImpl { Map params = new HashMap(11); params.put("id", id); - AuditApplicationEntity entity = (AuditApplicationEntity) template.queryForObject( + AuditApplicationEntity entity = (AuditApplicationEntity) template.selectOne( SELECT_APPLICATION_BY_ID, params); // Done @@ -121,7 +122,7 @@ public class AuditDAOImpl extends AbstractAuditDAOImpl Map params = new HashMap(11); params.put("id", appNamePair.getFirst()); - AuditApplicationEntity entity = (AuditApplicationEntity) template.queryForObject( + AuditApplicationEntity entity = (AuditApplicationEntity) template.selectOne( SELECT_APPLICATION_BY_NAME_ID, params); // Done @@ -140,8 +141,7 @@ public class AuditDAOImpl extends AbstractAuditDAOImpl entity.setApplicationNameId(appNameId); entity.setAuditModelId(modelId); entity.setDisabledPathsId(disabledPathsId); - Long id = (Long) template.insert(INSERT_APPLICATION, entity); - entity.setId(id); + template.insert(INSERT_APPLICATION, entity); return entity; } @@ -156,7 +156,13 @@ public class AuditDAOImpl extends AbstractAuditDAOImpl updateEntity.setAuditModelId(entity.getAuditModelId()); updateEntity.setDisabledPathsId(entity.getDisabledPathsId()); - template.update(UPDATE_APPLICATION, updateEntity, 1); + int updated = template.update(UPDATE_APPLICATION, updateEntity); + if (updated != 1) + { + // unexpected number of rows affected + throw new ConcurrencyFailureException("Incorrect number of rows affected for updateAuditApplication: " + updateEntity + ": expected 1, actual " + updated); + } + // Done return updateEntity; } @@ -186,8 +192,7 @@ public class AuditDAOImpl extends AbstractAuditDAOImpl entity.setAuditTime(time); entity.setAuditUserId(usernameId); entity.setAuditValuesId(valuesId); - Long id = (Long) template.insert(INSERT_ENTRY, entity); - entity.setId(id); + template.insert(INSERT_ENTRY, entity); return entity; } @@ -274,8 +279,8 @@ public class AuditDAOImpl extends AbstractAuditDAOImpl } } }; - - List rows = template.queryForList(SELECT_ENTRIES_WITHOUT_VALUES, params, 0, maxResults); + + List rows = (List) template.selectList(SELECT_ENTRIES_WITHOUT_VALUES, params, new RowBounds(0, maxResults)); for (AuditQueryResult row : rows) { resultsByValueId.put(row.getAuditValuesId(), row); @@ -303,23 +308,24 @@ public class AuditDAOImpl extends AbstractAuditDAOImpl } else { - // RowHandlers in RowHandlers: See 'groupBy' issue https://issues.apache.org/jira/browse/IBATIS-503 - RowHandler queryRowHandler = new RowHandler() + // RowHandlers in RowHandlers: See 'groupBy' issue for iBatis 2.x https://issues.apache.org/jira/browse/IBATIS-503 + ResultHandler queryResultHandler = new ResultHandler() { - public void handleRow(Object valueObject) + public void handleResult(ResultContext context) { - rowHandler.processResult((AuditQueryResult)valueObject); + rowHandler.processResult((AuditQueryResult)context.getResultObject()); } }; - RollupRowHandler rollupRowHandler = new RollupRowHandler( + RollupResultHandler rollupResultHandler = new RollupResultHandler( new String[] {"auditEntryId"}, "auditValueRows", - queryRowHandler, + queryResultHandler, maxResults); - template.queryWithRowHandler(rowHandler.valuesRequired() ? SELECT_ENTRIES_WITH_VALUES - : SELECT_ENTRIES_WITHOUT_VALUES, params, rollupRowHandler); - rollupRowHandler.processLastResults(); + template.select(rowHandler.valuesRequired() ? SELECT_ENTRIES_WITH_VALUES + : SELECT_ENTRIES_WITHOUT_VALUES, params, rollupResultHandler); + rollupResultHandler.processLastResults(); } } } + diff --git a/source/java/org/alfresco/repo/domain/avm/AbstractAVMVersionRootDAOImpl.java b/source/java/org/alfresco/repo/domain/avm/AbstractAVMVersionRootDAOImpl.java index b39da86d2b..5e2613304f 100644 --- a/source/java/org/alfresco/repo/domain/avm/AbstractAVMVersionRootDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/avm/AbstractAVMVersionRootDAOImpl.java @@ -94,7 +94,12 @@ public abstract class AbstractAVMVersionRootDAOImpl implements AVMVersionRootDAO ParameterCheck.mandatory("vrEntity.id", vrEntity.getId()); ParameterCheck.mandatory("vrEntity.version", vrEntity.getVersion()); - updateVersionRootEntity(vrEntity); + int updated = updateVersionRootEntity(vrEntity); + if (updated != 1) + { + // unexpected number of rows affected + throw new ConcurrencyFailureException("Incorrect number of rows affected for updateVersionRoot: " + vrEntity + ": expected 1, actual " + updated); + } // Cache it vrEntityCache.put(new Pair(vrEntity.getStoreId(), vrEntity.getVersion()), vrEntity.getId()); @@ -231,7 +236,7 @@ public abstract class AbstractAVMVersionRootDAOImpl implements AVMVersionRootDAO } protected abstract AVMVersionRootEntity createVersionRootEntity(AVMVersionRootEntity vrEntity); - protected abstract void updateVersionRootEntity(AVMVersionRootEntity updateVersionRootEntity); + protected abstract int updateVersionRootEntity(AVMVersionRootEntity updateVersionRootEntity); protected abstract int deleteVersionRootEntity(long vrEntityId); protected abstract AVMVersionRootEntity getVersionRootEntityMaxVersion(long storeId); protected abstract Long getVersionRootEntityMaxVersionId(long storeId); diff --git a/source/java/org/alfresco/repo/domain/avm/ibatis/AVMLockDAOImpl.java b/source/java/org/alfresco/repo/domain/avm/ibatis/AVMLockDAOImpl.java index f539b1f904..b22044bc60 100644 --- a/source/java/org/alfresco/repo/domain/avm/ibatis/AVMLockDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/avm/ibatis/AVMLockDAOImpl.java @@ -22,7 +22,7 @@ import java.util.HashMap; import java.util.Map; import org.alfresco.repo.domain.avm.AbstractAVMLockDAOImpl; -import org.springframework.orm.ibatis.SqlMapClientTemplate; +import org.mybatis.spring.SqlSessionTemplate; /** * iBatis-specific implementation of the AVMLock DAO. @@ -35,11 +35,12 @@ public class AVMLockDAOImpl extends AbstractAVMLockDAOImpl private static final String DELETE_MATCHING_AVM_LOCKS_1_KV ="alfresco.avm.delete_PropertyUniqueContextByValuesWithOneKV"; private static final String DELETE_MATCHING_AVM_LOCKS_0_KV ="alfresco.avm.delete_PropertyUniqueContextByValuesWithNoKV"; - private SqlMapClientTemplate template; - public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) + private SqlSessionTemplate template; + + public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) { - this.template = sqlMapClientTemplate; + this.template = sqlSessionTemplate; } @Override 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 2243c4fc51..5e5ebb2b51 100644 --- a/source/java/org/alfresco/repo/domain/avm/ibatis/AVMNodeDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/avm/ibatis/AVMNodeDAOImpl.java @@ -28,9 +28,10 @@ import org.alfresco.repo.domain.avm.AVMNodePropertyEntity; import org.alfresco.repo.domain.avm.AbstractAVMNodeDAOImpl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.orm.ibatis.SqlMapClientTemplate; - -import com.ibatis.sqlmap.client.event.RowHandler; +import org.apache.ibatis.session.ResultContext; +import org.apache.ibatis.session.ResultHandler; +import org.apache.ibatis.session.RowBounds; +import org.mybatis.spring.SqlSessionTemplate; /** * iBatis-specific implementation of the AVMNode DAO. @@ -42,7 +43,7 @@ public class AVMNodeDAOImpl extends AbstractAVMNodeDAOImpl { private static Log logger = LogFactory.getLog(AVMNodeDAOImpl.class); - private static final String INSERT_AVM_NODE = "alfresco.avm.insert_AVMNode"; + private static final String INSERT_AVM_NODE = "alfresco.avm.insert.insert_AVMNode"; private static final String SELECT_AVM_NODE_BY_ID = "alfresco.avm.select_AVMNodeById"; private static final String UPDATE_AVM_NODE = "alfresco.avm.update_AVMNode"; private static final String UPDATE_AVM_NODE_MODTIME_AND_GUID = "alfresco.avm.update_AVMNode_modTimeAndGuid"; @@ -60,29 +61,29 @@ public class AVMNodeDAOImpl extends AbstractAVMNodeDAOImpl private static final String SELECT_AVM_CONTENT_URLS_FOR_PLAIN_FILES = "alfresco.avm.select_ContentUrlsForPlainFiles"; private static final String SELECT_AVM_NODE_ASPECTS = "alfresco.avm.select_AVMNodeAspects"; - private static final String INSERT_AVM_NODE_ASPECT = "alfresco.avm.insert_AVMNodeAspect"; + private static final String INSERT_AVM_NODE_ASPECT = "alfresco.avm.insert.insert_AVMNodeAspect"; private static final String DELETE_AVM_NODE_ASPECT = "alfresco.avm.delete_AVMNodeAspect"; private static final String DELETE_AVM_NODE_ASPECTS = "alfresco.avm.delete_AVMNodeAspects"; - private static final String INSERT_AVM_NODE_PROP = "alfresco.avm.insert_AVMNodeProperty"; + private static final String INSERT_AVM_NODE_PROP = "alfresco.avm.insert.insert_AVMNodeProperty"; private static final String UPDATE_AVM_NODE_PROP = "alfresco.avm.update_AVMNodeProperty"; private static final String SELECT_AVM_NODE_PROP = "alfresco.avm.select_AVMNodeProperty"; private static final String SELECT_AVM_NODE_PROPS = "alfresco.avm.select_AVMNodeProperties"; private static final String DELETE_AVM_NODE_PROP = "alfresco.avm.delete_AVMNodeProperty"; private static final String DELETE_AVM_NODE_PROPS = "alfresco.avm.delete_AVMNodeProperties"; - private SqlMapClientTemplate template; - public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) + private SqlSessionTemplate template; + + public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) { - this.template = sqlMapClientTemplate; + this.template = sqlSessionTemplate; } @Override protected AVMNodeEntity createNodeEntity(AVMNodeEntity nodeEntity) { - Long id = (Long) template.insert(INSERT_AVM_NODE, nodeEntity); - nodeEntity.setId(id); + template.insert(INSERT_AVM_NODE, nodeEntity); return nodeEntity; } @@ -91,7 +92,7 @@ public class AVMNodeDAOImpl extends AbstractAVMNodeDAOImpl { Map params = new HashMap(1); params.put("id", id); - return (AVMNodeEntity) template.queryForObject(SELECT_AVM_NODE_BY_ID, params); + return (AVMNodeEntity) template.selectOne(SELECT_AVM_NODE_BY_ID, params); } @Override @@ -142,7 +143,7 @@ public class AVMNodeDAOImpl extends AbstractAVMNodeDAOImpl { Map params = new HashMap(1); params.put("id", storeId); - return (List) template.queryForList(SELECT_AVM_NODES_NEW_IN_STORE, params); + return (List) template.selectList(SELECT_AVM_NODES_NEW_IN_STORE, params); } @SuppressWarnings("unchecked") @@ -151,7 +152,7 @@ public class AVMNodeDAOImpl extends AbstractAVMNodeDAOImpl { Map params = new HashMap(1); params.put("id", storeId); - return (List) template.queryForList(SELECT_AVM_NODES_NEW_LAYERED_IN_STORE, params); + return (List) template.selectList(SELECT_AVM_NODES_NEW_LAYERED_IN_STORE, params); } @SuppressWarnings("unchecked") @@ -160,7 +161,7 @@ public class AVMNodeDAOImpl extends AbstractAVMNodeDAOImpl { Map params = new HashMap(1); params.put("id", storeId); - return (List) template.queryForList(SELECT_AVM_NODE_IDS_NEW_LAYERED_IN_STORE, params); + return (List) template.selectList(SELECT_AVM_NODE_IDS_NEW_LAYERED_IN_STORE, params); } @SuppressWarnings("unchecked") @@ -171,7 +172,7 @@ public class AVMNodeDAOImpl extends AbstractAVMNodeDAOImpl 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); + return (List) template.selectList(SELECT_AVM_NODES_NULL_PARENT_AND_ISROOT_TF, params, new RowBounds(0, maxSize)); } @SuppressWarnings("unchecked") @@ -182,45 +183,45 @@ public class AVMNodeDAOImpl extends AbstractAVMNodeDAOImpl params.put("bool", true); // all primary layered directories - return (List) template.queryForList(SELECT_AVM_NODES_LAYERED_DIRECTORIES_AND_PRIMARY_TF, params); + return (List) template.selectList(SELECT_AVM_NODES_LAYERED_DIRECTORIES_AND_PRIMARY_TF, params); } @SuppressWarnings("unchecked") @Override protected List getAllLayeredFileNodeEntities() { - return (List) template.queryForList(SELECT_AVM_NODES_LAYERED_FILES); + return (List) template.selectList(SELECT_AVM_NODES_LAYERED_FILES); } @Override protected void getPlainFileContentUrls(ContentUrlHandler handler) { - CleanRowHandler rowHandler = new CleanRowHandler(handler); + CleanResultHandler resultHandler = new CleanResultHandler(handler); - template.queryWithRowHandler(SELECT_AVM_CONTENT_URLS_FOR_PLAIN_FILES, rowHandler); + template.selectList(SELECT_AVM_CONTENT_URLS_FOR_PLAIN_FILES, resultHandler); if (logger.isDebugEnabled()) { - logger.debug(" Listed " + rowHandler.total + " content URLs"); + logger.debug(" Listed " + resultHandler.total + " content URLs"); } } /** * Row handler for cleaning content URLs */ - private static class CleanRowHandler implements RowHandler + private static class CleanResultHandler implements ResultHandler { private final ContentUrlHandler handler; private int total = 0; - private CleanRowHandler(ContentUrlHandler handler) + private CleanResultHandler(ContentUrlHandler handler) { this.handler = handler; } - public void handleRow(Object valueObject) + public void handleResult(ResultContext context) { - handler.handle((String)valueObject); + handler.handle((String)context.getResultObject()); total++; if (logger.isDebugEnabled() && (total == 0 || (total % 1000 == 0) )) { @@ -235,7 +236,7 @@ public class AVMNodeDAOImpl extends AbstractAVMNodeDAOImpl { Map params = new HashMap(1); params.put("id", nodeId); - return (List) template.queryForList(SELECT_AVM_NODE_ASPECTS, params); + return (List) template.selectList(SELECT_AVM_NODE_ASPECTS, params); } @Override @@ -279,7 +280,7 @@ public class AVMNodeDAOImpl extends AbstractAVMNodeDAOImpl propEntity.setNodeId(nodeId); propEntity.setQnameId(qnameId); - return (AVMNodePropertyEntity) template.queryForObject(SELECT_AVM_NODE_PROP, propEntity); + return (AVMNodePropertyEntity) template.selectOne(SELECT_AVM_NODE_PROP, propEntity); } @Override @@ -289,7 +290,7 @@ public class AVMNodeDAOImpl extends AbstractAVMNodeDAOImpl Map params = new HashMap(1); params.put("id", nodeId); - return (List) template.queryForList(SELECT_AVM_NODE_PROPS, params); + return (List) template.selectList(SELECT_AVM_NODE_PROPS, params); } @Override diff --git a/source/java/org/alfresco/repo/domain/avm/ibatis/AVMNodeLinksDAOImpl.java b/source/java/org/alfresco/repo/domain/avm/ibatis/AVMNodeLinksDAOImpl.java index 6638cbc2f3..28286ff55e 100644 --- a/source/java/org/alfresco/repo/domain/avm/ibatis/AVMNodeLinksDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/avm/ibatis/AVMNodeLinksDAOImpl.java @@ -26,7 +26,7 @@ import org.alfresco.repo.domain.avm.AVMChildEntryEntity; import org.alfresco.repo.domain.avm.AVMHistoryLinkEntity; import org.alfresco.repo.domain.avm.AVMMergeLinkEntity; import org.alfresco.repo.domain.avm.AbstractAVMNodeLinksDAOImpl; -import org.springframework.orm.ibatis.SqlMapClientTemplate; +import org.mybatis.spring.SqlSessionTemplate; /** * iBatis-specific implementation of the AVMNodeLinks DAO. @@ -50,7 +50,7 @@ public class AVMNodeLinksDAOImpl extends AbstractAVMNodeLinksDAOImpl private static final String SELECT_AVM_NODE_CHILD_ENTRIES_BY_CHILD ="alfresco.avm.select_AVMNodeChildEntriesByChild"; // child - private static final String INSERT_AVM_NODE_CHILD_ENTRY ="alfresco.avm.insert_AVMChildEntry"; // parent + name + child + private static final String INSERT_AVM_NODE_CHILD_ENTRY ="alfresco.avm.insert.insert_AVMChildEntry"; // parent + name + child private static final String UPDATE_AVM_NODE_CHILD_ENTRY ="alfresco.avm.update_AVMChildEntry"; // parent + child (update name) @@ -60,30 +60,32 @@ public class AVMNodeLinksDAOImpl extends AbstractAVMNodeLinksDAOImpl private static final String DELETE_AVM_NODE_CHILD_ENTRY_BY_PARENT_AND_CHILD ="alfresco.avm.delete_AVMChildEntryByParentAndChild"; // parent + child private static final String DELETE_AVM_NODE_CHILD_ENTRIES_BY_PARENT ="alfresco.avm.delete_AVMNodeChildEntriesByParent"; // parent - private static final String INSERT_AVM_MERGE_LINK ="alfresco.avm.insert_AVMMergeLink"; + private static final String INSERT_AVM_MERGE_LINK ="alfresco.avm.insert.insert_AVMMergeLink"; private static final String DELETE_AVM_MERGE_LINK ="alfresco.avm.delete_AVMMergeLink"; private static final String SELECT_AVM_MERGE_LINKS_BY_FROM ="alfresco.avm.select_AVMMergeLinksByFrom"; private static final String SELECT_AVM_MERGE_LINK_BY_TO ="alfresco.avm.select_AVMMergeLinkByTo"; - private static final String INSERT_AVM_HISTORY_LINK ="alfresco.avm.insert_AVMHistoryLink"; + private static final String INSERT_AVM_HISTORY_LINK ="alfresco.avm.insert.insert_AVMHistoryLink"; private static final String DELETE_AVM_HISTORY_LINK ="alfresco.avm.delete_AVMHistoryLink"; private static final String SELECT_AVM_HISTORY_LINKS_BY_ANCESTOR ="alfresco.avm.select_AVMHistoryLinksByAncestor"; private static final String SELECT_AVM_HISTORY_LINK_BY_DESCENDENT ="alfresco.avm.select_AVMHistoryLinkByDescendent"; private static final String SELECT_AVM_HISTORY_LINK ="alfresco.avm.select_AVMHistoryLink"; - private SqlMapClientTemplate template; + + private SqlSessionTemplate template; + + public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) + { + this.template = sqlSessionTemplate; + } + // Initial generic fix for ALF-1940 (pending SAIL-349) // Note: in order to override to false DB must be setup to be case-insensitive (at least on column avm_child_entries.name) private boolean toLower = true; - public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) - { - this.template = sqlMapClientTemplate; - } - public void setToLower(boolean toLower) { this.toLower = toLower; @@ -94,9 +96,9 @@ public class AVMNodeLinksDAOImpl extends AbstractAVMNodeLinksDAOImpl { if (toLower) { - return (AVMChildEntryEntity) template.queryForObject(SELECT_AVM_NODE_CHILD_ENTRY_L, childEntryEntity); + return (AVMChildEntryEntity) template.selectOne(SELECT_AVM_NODE_CHILD_ENTRY_L, childEntryEntity); } - return (AVMChildEntryEntity) template.queryForObject(SELECT_AVM_NODE_CHILD_ENTRY, childEntryEntity); + return (AVMChildEntryEntity) template.selectOne(SELECT_AVM_NODE_CHILD_ENTRY, childEntryEntity); } @Override @@ -106,16 +108,16 @@ public class AVMNodeLinksDAOImpl extends AbstractAVMNodeLinksDAOImpl if (toLower) { - return (AVMChildEntryEntity) template.queryForObject(SELECT_AVM_NODE_CHILD_ENTRY_BY_PARENT_AND_NAME_L, childEntryEntity); + return (AVMChildEntryEntity) template.selectOne(SELECT_AVM_NODE_CHILD_ENTRY_BY_PARENT_AND_NAME_L, childEntryEntity); } - return (AVMChildEntryEntity) template.queryForObject(SELECT_AVM_NODE_CHILD_ENTRY_BY_PARENT_AND_NAME, childEntryEntity); + return (AVMChildEntryEntity) template.selectOne(SELECT_AVM_NODE_CHILD_ENTRY_BY_PARENT_AND_NAME, childEntryEntity); } @Override protected AVMChildEntryEntity getChildEntryEntity(long parentNodeId, long childNodeId) { AVMChildEntryEntity childEntryEntity = new AVMChildEntryEntity(parentNodeId, childNodeId); - return (AVMChildEntryEntity) template.queryForObject(SELECT_AVM_NODE_CHILD_ENTRY_BY_PARENT_AND_CHILD, childEntryEntity); + return (AVMChildEntryEntity) template.selectOne(SELECT_AVM_NODE_CHILD_ENTRY_BY_PARENT_AND_CHILD, childEntryEntity); } @SuppressWarnings("unchecked") @@ -124,7 +126,7 @@ public class AVMNodeLinksDAOImpl extends AbstractAVMNodeLinksDAOImpl { Map params = new HashMap(1); params.put("id", parentNodeId); - return (List) template.queryForList(SELECT_AVM_NODE_CHILD_ENTRIES_BY_PARENT, params); + return (List) template.selectList(SELECT_AVM_NODE_CHILD_ENTRIES_BY_PARENT, params); } @SuppressWarnings("unchecked") @@ -137,9 +139,9 @@ public class AVMNodeLinksDAOImpl extends AbstractAVMNodeLinksDAOImpl if (toLower) { - return (List) template.queryForList(SELECT_AVM_NODE_CHILD_ENTRIES_BY_PARENT_AND_NAME_PATTERN_L, params); + return (List) template.selectList(SELECT_AVM_NODE_CHILD_ENTRIES_BY_PARENT_AND_NAME_PATTERN_L, params); } - return (List) template.queryForList(SELECT_AVM_NODE_CHILD_ENTRIES_BY_PARENT_AND_NAME_PATTERN, params); + return (List) template.selectList(SELECT_AVM_NODE_CHILD_ENTRIES_BY_PARENT_AND_NAME_PATTERN, params); } @SuppressWarnings("unchecked") @@ -148,7 +150,7 @@ public class AVMNodeLinksDAOImpl extends AbstractAVMNodeLinksDAOImpl { Map params = new HashMap(1); params.put("id", childNodeId); - return (List) template.queryForList(SELECT_AVM_NODE_CHILD_ENTRIES_BY_CHILD, params); + return (List) template.selectList(SELECT_AVM_NODE_CHILD_ENTRIES_BY_CHILD, params); } @Override @@ -213,7 +215,7 @@ public class AVMNodeLinksDAOImpl extends AbstractAVMNodeLinksDAOImpl { Map params = new HashMap(1); params.put("id", mergeToNodeId); - return (AVMMergeLinkEntity) template.queryForObject(SELECT_AVM_MERGE_LINK_BY_TO, params); + return (AVMMergeLinkEntity) template.selectOne(SELECT_AVM_MERGE_LINK_BY_TO, params); } @SuppressWarnings("unchecked") @@ -222,7 +224,7 @@ public class AVMNodeLinksDAOImpl extends AbstractAVMNodeLinksDAOImpl { Map params = new HashMap(1); params.put("id", mergeFromNodeId); - return (List) template.queryForList(SELECT_AVM_MERGE_LINKS_BY_FROM, params); + return (List) template.selectList(SELECT_AVM_MERGE_LINKS_BY_FROM, params); } @@ -245,14 +247,14 @@ public class AVMNodeLinksDAOImpl extends AbstractAVMNodeLinksDAOImpl { Map params = new HashMap(1); params.put("id", descendentNodeId); - return (AVMHistoryLinkEntity) template.queryForObject(SELECT_AVM_HISTORY_LINK_BY_DESCENDENT, params); + return (AVMHistoryLinkEntity) template.selectOne(SELECT_AVM_HISTORY_LINK_BY_DESCENDENT, params); } @Override protected AVMHistoryLinkEntity getHistoryLinkEntity(long ancestorNodeId, long descendentNodeId) { AVMHistoryLinkEntity hLinkEntity = new AVMHistoryLinkEntity(ancestorNodeId, descendentNodeId); - return (AVMHistoryLinkEntity) template.queryForObject(SELECT_AVM_HISTORY_LINK, hLinkEntity); + return (AVMHistoryLinkEntity) template.selectOne(SELECT_AVM_HISTORY_LINK, hLinkEntity); } @SuppressWarnings("unchecked") @@ -261,6 +263,6 @@ public class AVMNodeLinksDAOImpl extends AbstractAVMNodeLinksDAOImpl { Map params = new HashMap(1); params.put("id", ancestorNodeId); - return (List) template.queryForList(SELECT_AVM_HISTORY_LINKS_BY_ANCESTOR, params); + return (List) template.selectList(SELECT_AVM_HISTORY_LINKS_BY_ANCESTOR, params); } } diff --git a/source/java/org/alfresco/repo/domain/avm/ibatis/AVMStoreDAOImpl.java b/source/java/org/alfresco/repo/domain/avm/ibatis/AVMStoreDAOImpl.java index fc46f9f922..f38abfc727 100644 --- a/source/java/org/alfresco/repo/domain/avm/ibatis/AVMStoreDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/avm/ibatis/AVMStoreDAOImpl.java @@ -25,7 +25,7 @@ import java.util.Map; import org.alfresco.repo.domain.avm.AVMStoreEntity; import org.alfresco.repo.domain.avm.AVMStorePropertyEntity; import org.alfresco.repo.domain.avm.AbstractAVMStoreDAOImpl; -import org.springframework.orm.ibatis.SqlMapClientTemplate; +import org.mybatis.spring.SqlSessionTemplate; /** * iBatis-specific implementation of the AVMStore DAO. @@ -43,11 +43,11 @@ public class AVMStoreDAOImpl extends AbstractAVMStoreDAOImpl private static final String SELECT_AVM_STORE_BY_ROOT_NODE_ID ="alfresco.avm.select_AVMStoreByRootNodeId"; private static final String SELECT_AVM_STORE_ALL ="alfresco.avm.select_AVMStoreAll"; - private static final String INSERT_AVM_STORE ="alfresco.avm.insert_AVMStore"; + private static final String INSERT_AVM_STORE ="alfresco.avm.insert.insert_AVMStore"; private static final String DELETE_AVM_STORE ="alfresco.avm.delete_AVMStore"; private static final String UPDATE_AVM_STORE ="alfresco.avm.update_AVMStore"; - private static final String INSERT_AVM_STORE_PROP ="alfresco.avm.insert_AVMStoreProperty"; + private static final String INSERT_AVM_STORE_PROP ="alfresco.avm.insert.insert_AVMStoreProperty"; private static final String UPDATE_AVM_STORE_PROP ="alfresco.avm.update_AVMStoreProperty"; private static final String SELECT_AVM_STORE_PROP ="alfresco.avm.select_AVMStoreProperty"; private static final String SELECT_AVM_STORE_PROPS ="alfresco.avm.select_AVMStoreProperties"; @@ -62,17 +62,18 @@ public class AVMStoreDAOImpl extends AbstractAVMStoreDAOImpl private static final String DELETE_AVM_STORE_PROPS ="alfresco.avm.delete_AVMStoreProperties"; - private SqlMapClientTemplate template; + private SqlSessionTemplate template; + + public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) + { + this.template = sqlSessionTemplate; + } + // Initial generic fixes for ALF-2278 (pending SAIL-365) & ALF-498 (pending SAIL-359) // Note: in order to override to false, DB must be setup to be case-insensitive (at least on column avm_stores.name) private boolean toLower = true; - public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) - { - this.template = sqlMapClientTemplate; - } - public void setToLower(boolean toLower) { this.toLower = toLower; @@ -83,7 +84,7 @@ public class AVMStoreDAOImpl extends AbstractAVMStoreDAOImpl { Map params = new HashMap(1); params.put("id", id); - return (AVMStoreEntity) template.queryForObject(SELECT_AVM_STORE_BY_ID, params); + return (AVMStoreEntity) template.selectOne(SELECT_AVM_STORE_BY_ID, params); } @Override @@ -94,9 +95,9 @@ public class AVMStoreDAOImpl extends AbstractAVMStoreDAOImpl if (toLower) { - return (AVMStoreEntity) template.queryForObject(SELECT_AVM_STORE_BY_KEY_L, storeEntity); + return (AVMStoreEntity) template.selectOne(SELECT_AVM_STORE_BY_KEY_L, storeEntity); } - return (AVMStoreEntity) template.queryForObject(SELECT_AVM_STORE_BY_KEY, storeEntity); + return (AVMStoreEntity) template.selectOne(SELECT_AVM_STORE_BY_KEY, storeEntity); } @Override @@ -104,21 +105,20 @@ public class AVMStoreDAOImpl extends AbstractAVMStoreDAOImpl { Map params = new HashMap(1); params.put("id", rootNodeId); - return (AVMStoreEntity) template.queryForObject(SELECT_AVM_STORE_BY_ROOT_NODE_ID, params); + return (AVMStoreEntity) template.selectOne(SELECT_AVM_STORE_BY_ROOT_NODE_ID, params); } @SuppressWarnings("unchecked") @Override protected List getAllStoreEntities() { - return (List) template.queryForList(SELECT_AVM_STORE_ALL); + return (List) template.selectList(SELECT_AVM_STORE_ALL); } @Override protected AVMStoreEntity createStoreEntity(AVMStoreEntity storeEntity) { - Long id = (Long) template.insert(INSERT_AVM_STORE, storeEntity); - storeEntity.setId(id); + template.insert(INSERT_AVM_STORE, storeEntity); return storeEntity; } @@ -157,7 +157,7 @@ public class AVMStoreDAOImpl extends AbstractAVMStoreDAOImpl propEntity.setAvmStoreId(storeId); propEntity.setQnameId(qnameId); - return (AVMStorePropertyEntity) template.queryForObject(SELECT_AVM_STORE_PROP, propEntity); + return (AVMStorePropertyEntity) template.selectOne(SELECT_AVM_STORE_PROP, propEntity); } @SuppressWarnings("unchecked") @@ -169,7 +169,7 @@ public class AVMStoreDAOImpl extends AbstractAVMStoreDAOImpl try { - return (List) template.queryForList(SELECT_AVM_STORE_PROPS, params); + return (List) template.selectList(SELECT_AVM_STORE_PROPS, params); } catch (Throwable e) { @@ -187,9 +187,9 @@ public class AVMStoreDAOImpl extends AbstractAVMStoreDAOImpl if (toLower) { - return (List) template.queryForList(SELECT_AVM_STORE_PROPS_BY_KEY_PATTERN_L, params); + return (List) template.selectList(SELECT_AVM_STORE_PROPS_BY_KEY_PATTERN_L, params); } - return (List) template.queryForList(SELECT_AVM_STORE_PROPS_BY_KEY_PATTERN, params); + return (List) template.selectList(SELECT_AVM_STORE_PROPS_BY_KEY_PATTERN, params); } @SuppressWarnings("unchecked") @@ -203,9 +203,9 @@ public class AVMStoreDAOImpl extends AbstractAVMStoreDAOImpl if (toLower) { - return (List) template.queryForList(SELECT_AVM_STORE_PROPS_BY_STORE_AND_KEY_PATTERN_L, params); + return (List) template.selectList(SELECT_AVM_STORE_PROPS_BY_STORE_AND_KEY_PATTERN_L, params); } - return (List) template.queryForList(SELECT_AVM_STORE_PROPS_BY_STORE_AND_KEY_PATTERN, params); + return (List) template.selectList(SELECT_AVM_STORE_PROPS_BY_STORE_AND_KEY_PATTERN, params); } @Override diff --git a/source/java/org/alfresco/repo/domain/avm/ibatis/AVMVersionRootDAOImpl.java b/source/java/org/alfresco/repo/domain/avm/ibatis/AVMVersionRootDAOImpl.java index 1a0fab5ae7..7ffe6c056d 100644 --- a/source/java/org/alfresco/repo/domain/avm/ibatis/AVMVersionRootDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/avm/ibatis/AVMVersionRootDAOImpl.java @@ -26,7 +26,7 @@ import org.alfresco.repo.domain.avm.AVMStoreEntity; import org.alfresco.repo.domain.avm.AVMVersionLayeredNodeEntryEntity; import org.alfresco.repo.domain.avm.AVMVersionRootEntity; import org.alfresco.repo.domain.avm.AbstractAVMVersionRootDAOImpl; -import org.springframework.orm.ibatis.SqlMapClientTemplate; +import org.mybatis.spring.SqlSessionTemplate; /** * iBatis-specific implementation of the AVMVersionRoot DAO @@ -36,7 +36,7 @@ import org.springframework.orm.ibatis.SqlMapClientTemplate; */ public class AVMVersionRootDAOImpl extends AbstractAVMVersionRootDAOImpl { - private static final String INSERT_AVM_VERSION_ROOT ="alfresco.avm.insert_AVMVersionRoot"; + private static final String INSERT_AVM_VERSION_ROOT ="alfresco.avm.insert.insert_AVMVersionRoot"; private static final String DELETE_AVM_VERSION_ROOT ="alfresco.avm.delete_AVMVersionRoot"; private static final String UPDATE_AVM_VERSION_ROOT ="alfresco.avm.update_AVMVersionRoot"; @@ -54,30 +54,30 @@ public class AVMVersionRootDAOImpl extends AbstractAVMVersionRootDAOImpl private static final String SELECT_AVM_VERSION_ROOTS_BY_VERSION_FROM ="alfresco.avm.select_AVMVersionRootsByVersionFrom"; private static final String SELECT_AVM_VERSION_ROOTS_BY_VERSIONS_BETWEEN ="alfresco.avm.select_AVMVersionRootsByVersionsBetween"; - private static final String INSERT_AVM_VERSION_LAYERED_NODE_ENTRY ="alfresco.avm.insert_AVMVersionLayeredNodeEntry"; + private static final String INSERT_AVM_VERSION_LAYERED_NODE_ENTRY ="alfresco.avm.insert.insert_AVMVersionLayeredNodeEntry"; private static final String DELETE_AVM_VERSION_LAYERED_NODE_ENTRIES ="alfresco.avm.delete_AVMVersionLayeredNodeEntries"; private static final String SELECT_AVM_VERSION_LAYERED_NODE_ENTRIES ="alfresco.avm.select_AVMVersionLayeredNodeEntries"; - private SqlMapClientTemplate template; + private SqlSessionTemplate template; - public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) + public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) { - this.template = sqlMapClientTemplate; + this.template = sqlSessionTemplate; } + @Override protected AVMVersionRootEntity createVersionRootEntity(AVMVersionRootEntity newVersionRootEntity) { - Long id = (Long) template.insert(INSERT_AVM_VERSION_ROOT, newVersionRootEntity); - newVersionRootEntity.setId(id); + template.insert(INSERT_AVM_VERSION_ROOT, newVersionRootEntity); return newVersionRootEntity; } @Override - protected void updateVersionRootEntity(AVMVersionRootEntity updateVersionRootEntity) + protected int updateVersionRootEntity(AVMVersionRootEntity updateVersionRootEntity) { - template.update(UPDATE_AVM_VERSION_ROOT, updateVersionRootEntity, 1); + return template.update(UPDATE_AVM_VERSION_ROOT, updateVersionRootEntity); } @Override @@ -85,7 +85,7 @@ public class AVMVersionRootDAOImpl extends AbstractAVMVersionRootDAOImpl { AVMStoreEntity storeEntity = new AVMStoreEntity(); storeEntity.setId(storeId); - return (AVMVersionRootEntity) template.queryForObject(SELECT_AVM_VERSION_ROOT_MAX_VERSION, storeEntity); + return (AVMVersionRootEntity) template.selectOne(SELECT_AVM_VERSION_ROOT_MAX_VERSION, storeEntity); } @Override @@ -93,7 +93,7 @@ public class AVMVersionRootDAOImpl extends AbstractAVMVersionRootDAOImpl { Map params = new HashMap(1); params.put("id", storeId); - Integer maxVersionId = (Integer) template.queryForObject(SELECT_AVM_VERSION_ROOT_MAX_VERSION_ID, params); + Integer maxVersionId = (Integer) template.selectOne(SELECT_AVM_VERSION_ROOT_MAX_VERSION_ID, params); if (maxVersionId == null) { return null; @@ -106,7 +106,7 @@ public class AVMVersionRootDAOImpl extends AbstractAVMVersionRootDAOImpl { Map params = new HashMap(1); params.put("id", vrEntityId); - return (AVMVersionRootEntity) template.queryForObject(SELECT_AVM_VERSION_ROOT_BY_ID, params); + return (AVMVersionRootEntity) template.selectOne(SELECT_AVM_VERSION_ROOT_BY_ID, params); } @Override @@ -116,7 +116,7 @@ public class AVMVersionRootDAOImpl extends AbstractAVMVersionRootDAOImpl vrEntity.setStoreId(storeId); vrEntity.setVersion(version); - return (AVMVersionRootEntity) template.queryForObject(SELECT_AVM_VERSION_ROOT_BY_STORE_VERSION, vrEntity); + return (AVMVersionRootEntity) template.selectOne(SELECT_AVM_VERSION_ROOT_BY_STORE_VERSION, vrEntity); } @Override @@ -124,7 +124,7 @@ public class AVMVersionRootDAOImpl extends AbstractAVMVersionRootDAOImpl { Map params = new HashMap(1); params.put("id", rootNodeId); - return (AVMVersionRootEntity) template.queryForObject(SELECT_AVM_VERSION_ROOT_BY_ROOT_NODE_ID, params); + return (AVMVersionRootEntity) template.selectOne(SELECT_AVM_VERSION_ROOT_BY_ROOT_NODE_ID, params); } @SuppressWarnings("unchecked") @@ -133,7 +133,7 @@ public class AVMVersionRootDAOImpl extends AbstractAVMVersionRootDAOImpl { Map params = new HashMap(1); params.put("id", storeId); - return (List) template.queryForList(SELECT_AVM_VERSION_ROOTS_BY_STORE_ID, params); + return (List) template.selectList(SELECT_AVM_VERSION_ROOTS_BY_STORE_ID, params); } @SuppressWarnings("unchecked") @@ -142,7 +142,7 @@ public class AVMVersionRootDAOImpl extends AbstractAVMVersionRootDAOImpl Map params = new HashMap(2); params.put("id", storeId); params.put("to", to); - return (List) template.queryForList(SELECT_AVM_VERSION_ROOTS_BY_DATE_TO, params); + return (List) template.selectList(SELECT_AVM_VERSION_ROOTS_BY_DATE_TO, params); } @SuppressWarnings("unchecked") @@ -151,7 +151,7 @@ public class AVMVersionRootDAOImpl extends AbstractAVMVersionRootDAOImpl Map params = new HashMap(2); params.put("id", storeId); params.put("from", from); - return (List) template.queryForList(SELECT_AVM_VERSION_ROOTS_BY_DATE_FROM, params); + return (List) template.selectList(SELECT_AVM_VERSION_ROOTS_BY_DATE_FROM, params); } @SuppressWarnings("unchecked") @@ -161,9 +161,10 @@ public class AVMVersionRootDAOImpl extends AbstractAVMVersionRootDAOImpl params.put("id", storeId); params.put("from", from); params.put("to", to); - return (List) template.queryForList(SELECT_AVM_VERSION_ROOTS_BY_DATES_BETWEEN, params); + return (List) template.selectList(SELECT_AVM_VERSION_ROOTS_BY_DATES_BETWEEN, params); } + @SuppressWarnings("unchecked") @Override protected List getVersionRootEntitiesByVersionsBetween(long storeId, long from, long to) { @@ -171,25 +172,27 @@ public class AVMVersionRootDAOImpl extends AbstractAVMVersionRootDAOImpl params.put("id", storeId); params.put("from", from); params.put("to", to); - return (List) template.queryForList(SELECT_AVM_VERSION_ROOTS_BY_VERSIONS_BETWEEN, params); + return (List) template.selectList(SELECT_AVM_VERSION_ROOTS_BY_VERSIONS_BETWEEN, params); } + @SuppressWarnings("unchecked") @Override protected List getVersionRootEntitiesByVersionsFrom(long storeId, long from) { Map params = new HashMap(2); params.put("id", storeId); params.put("from", from); - return (List) template.queryForList(SELECT_AVM_VERSION_ROOTS_BY_VERSION_FROM, params); + return (List) template.selectList(SELECT_AVM_VERSION_ROOTS_BY_VERSION_FROM, params); } + @SuppressWarnings("unchecked") @Override protected List getVersionRootEntitiesByVersionsTo(long storeId, long to) { Map params = new HashMap(2); params.put("id", storeId); params.put("to", to); - return (List) template.queryForList(SELECT_AVM_VERSION_ROOTS_BY_VERSION_TO, params); + return (List) template.selectList(SELECT_AVM_VERSION_ROOTS_BY_VERSION_TO, params); } @Override @@ -225,6 +228,6 @@ public class AVMVersionRootDAOImpl extends AbstractAVMVersionRootDAOImpl { Map params = new HashMap(1); params.put("id", versionRootId); - return (List) template.queryForList(SELECT_AVM_VERSION_LAYERED_NODE_ENTRIES, params); + return (List) template.selectList(SELECT_AVM_VERSION_LAYERED_NODE_ENTRIES, params); } } diff --git a/source/java/org/alfresco/repo/domain/contentdata/ibatis/ContentDataDAOImpl.java b/source/java/org/alfresco/repo/domain/contentdata/ibatis/ContentDataDAOImpl.java index 5d6d584f42..7d95b5bb03 100644 --- a/source/java/org/alfresco/repo/domain/contentdata/ibatis/ContentDataDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/contentdata/ibatis/ContentDataDAOImpl.java @@ -35,9 +35,10 @@ import org.alfresco.repo.domain.contentdata.ContentUrlUpdateEntity; import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.util.Pair; import org.alfresco.util.ParameterCheck; +import org.apache.ibatis.session.RowBounds; +import org.mybatis.spring.SqlSessionTemplate; import org.springframework.dao.ConcurrencyFailureException; import org.springframework.dao.DataIntegrityViolationException; -import org.springframework.orm.ibatis.SqlMapClientTemplate; /** * iBatis-specific implementation of the ContentData DAO. @@ -53,27 +54,30 @@ public class ContentDataDAOImpl extends AbstractContentDataDAOImpl private static final String SELECT_CONTENT_URLS_ORPHANED = "alfresco.content.select_ContentUrlsOrphaned"; private static final String SELECT_CONTENT_DATA_BY_ID = "alfresco.content.select_ContentDataById"; private static final String SELECT_CONTENT_DATA_BY_NODE_AND_QNAME = "alfresco.content.select_ContentDataByNodeAndQName"; - private static final String INSERT_CONTENT_URL = "alfresco.content.insert_ContentUrl"; - private static final String INSERT_CONTENT_DATA = "alfresco.content.insert_ContentData"; + private static final String INSERT_CONTENT_URL = "alfresco.content.insert.insert_ContentUrl"; + private static final String INSERT_CONTENT_DATA = "alfresco.content.insert.insert_ContentData"; private static final String UPDATE_CONTENT_URL_ORPHAN_TIME = "alfresco.content.update_ContentUrlOrphanTime"; private static final String UPDATE_CONTENT_DATA = "alfresco.content.update_ContentData"; private static final String DELETE_CONTENT_DATA = "alfresco.content.delete_ContentData"; private static final String DELETE_CONTENT_URLS = "alfresco.content.delete_ContentUrls"; - private SqlMapClientTemplate template; - - public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) + + private SqlSessionTemplate template; + + public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) { - this.template = sqlMapClientTemplate; + this.template = sqlSessionTemplate; } - + + public Pair createContentUrlOrphaned(String contentUrl, Date orphanTime) { ContentUrlEntity contentUrlEntity = new ContentUrlEntity(); contentUrlEntity.setContentUrl(contentUrl); contentUrlEntity.setSize(0L); contentUrlEntity.setOrphanTime(orphanTime == null ? System.currentTimeMillis() : orphanTime.getTime()); - Long id = (Long) template.insert(INSERT_CONTENT_URL, contentUrlEntity); + template.insert(INSERT_CONTENT_URL, contentUrlEntity); + Long id = contentUrlEntity.getId(); // Done return new Pair(id, contentUrl); } @@ -97,7 +101,7 @@ public class ContentDataDAOImpl extends AbstractContentDataDAOImpl { ContentUrlEntity contentUrlEntity = new ContentUrlEntity(); contentUrlEntity.setId(id); - contentUrlEntity = (ContentUrlEntity) template.queryForObject(SELECT_CONTENT_URL_BY_ID, contentUrlEntity); + contentUrlEntity = (ContentUrlEntity) template.selectOne(SELECT_CONTENT_URL_BY_ID, contentUrlEntity); // Done return contentUrlEntity; } @@ -111,7 +115,7 @@ public class ContentDataDAOImpl extends AbstractContentDataDAOImpl { contentUrlEntity.setContentUrlShort(contentUrlEntity.getContentUrlShort().toLowerCase()); } - contentUrlEntity = (ContentUrlEntity) template.queryForObject(SELECT_CONTENT_URL_BY_KEY, contentUrlEntity); + contentUrlEntity = (ContentUrlEntity) template.selectOne(SELECT_CONTENT_URL_BY_KEY, contentUrlEntity); // Done return contentUrlEntity; } @@ -126,9 +130,9 @@ public class ContentDataDAOImpl extends AbstractContentDataDAOImpl ContentUrlOrphanQuery query = new ContentUrlOrphanQuery(); query.setMaxOrphanTimeExclusive(maxOrphanTimeExclusive); - List results = template.queryForList( - SELECT_CONTENT_URLS_ORPHANED, - query, 0, maxResults); + List results = (List) template.selectList(SELECT_CONTENT_URLS_ORPHANED, + query, + new RowBounds(0, maxResults)); // Pass the result to the callback for (ContentUrlEntity result : results) { @@ -165,7 +169,7 @@ public class ContentDataDAOImpl extends AbstractContentDataDAOImpl { contentUrlEntity.setContentUrlShort(contentUrlEntity.getContentUrlShort().toLowerCase()); } - contentUrlEntity = (ContentUrlEntity) template.queryForObject(SELECT_CONTENT_URL_BY_KEY_UNREFERENCED, contentUrlEntity); + contentUrlEntity = (ContentUrlEntity) template.selectOne(SELECT_CONTENT_URL_BY_KEY_UNREFERENCED, contentUrlEntity); // Done return contentUrlEntity; } @@ -200,7 +204,7 @@ public class ContentDataDAOImpl extends AbstractContentDataDAOImpl { Map params = new HashMap(11); params.put("id", id); - ContentDataEntity contentDataEntity = (ContentDataEntity) template.queryForObject(SELECT_CONTENT_DATA_BY_ID, params); + ContentDataEntity contentDataEntity = (ContentDataEntity) template.selectOne(SELECT_CONTENT_DATA_BY_ID, params); // Done return contentDataEntity; } @@ -247,7 +251,7 @@ public class ContentDataDAOImpl extends AbstractContentDataDAOImpl idsEntity.setIdOne(nodeId); idsEntity.setIds(new ArrayList(qnameIds)); @SuppressWarnings("unchecked") - List ids = (List) template.queryForList(SELECT_CONTENT_DATA_BY_NODE_AND_QNAME, idsEntity); + List ids = (List) template.selectList(SELECT_CONTENT_DATA_BY_NODE_AND_QNAME, idsEntity); // Delete each one for (Long id : ids) { diff --git a/source/java/org/alfresco/repo/domain/control/ibatis/ControlDAOImpl.java b/source/java/org/alfresco/repo/domain/control/ibatis/ControlDAOImpl.java index ae356c3de5..0f03095b84 100644 --- a/source/java/org/alfresco/repo/domain/control/ibatis/ControlDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/control/ibatis/ControlDAOImpl.java @@ -23,10 +23,7 @@ import java.sql.SQLException; import java.sql.Savepoint; import org.alfresco.repo.domain.control.AbstractControlDAOImpl; -import org.springframework.jdbc.datasource.DataSourceUtils; -import org.springframework.orm.ibatis.SqlMapClientTemplate; - -import com.ibatis.sqlmap.client.SqlMapClient; +import org.mybatis.spring.SqlSessionTemplate; /** * iBatis-specific, DB-agnostic implementation for connection controlling DAO. @@ -37,13 +34,13 @@ import com.ibatis.sqlmap.client.SqlMapClient; public class ControlDAOImpl extends AbstractControlDAOImpl { /** - * The iBatis-specific template for convenient statement execution. + * The myBatis-specific template for convenient statement execution. */ - protected SqlMapClientTemplate template; + protected SqlSessionTemplate template; - public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) + public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) { - this.template = sqlMapClientTemplate; + this.template = sqlSessionTemplate; } public void startBatch() @@ -53,6 +50,7 @@ public class ControlDAOImpl extends AbstractControlDAOImpl * don't have any effect other than to let iBatis know that a batch * is possible. */ + /* SqlMapClient sqlMapClient = template.getSqlMapClient(); try { @@ -63,6 +61,7 @@ public class ControlDAOImpl extends AbstractControlDAOImpl { throw new RuntimeException("Failed to start DAO batch.", e); } + */ } public void executeBatch() @@ -72,6 +71,7 @@ public class ControlDAOImpl extends AbstractControlDAOImpl * don't have any effect other than to let iBatis know that a batch * is possible. */ + /* SqlMapClient sqlMapClient = template.getSqlMapClient(); try { @@ -81,8 +81,9 @@ public class ControlDAOImpl extends AbstractControlDAOImpl } catch (SQLException e) { - throw new RuntimeException("Failed to start DAO batch.", e); + throw new RuntimeException("Failed to execute DAO batch.", e); } + */ } /** @@ -101,7 +102,7 @@ public class ControlDAOImpl extends AbstractControlDAOImpl { try { - Connection connection = DataSourceUtils.getConnection(template.getDataSource()); + Connection connection = template.getConnection(); return connection.setSavepoint(savepoint); } catch (SQLException e) @@ -117,7 +118,7 @@ public class ControlDAOImpl extends AbstractControlDAOImpl { try { - Connection connection = DataSourceUtils.getConnection(template.getDataSource()); + Connection connection = template.getConnection(); connection.rollback(savepoint); } catch (SQLException e) @@ -130,7 +131,7 @@ public class ControlDAOImpl extends AbstractControlDAOImpl { try { - Connection connection = DataSourceUtils.getConnection(template.getDataSource()); + Connection connection = template.getConnection(); connection.releaseSavepoint(savepoint); } catch (SQLException e) @@ -143,7 +144,7 @@ public class ControlDAOImpl extends AbstractControlDAOImpl @Override public int setTransactionIsolationLevel(int isolationLevel) { - Connection connection = DataSourceUtils.getConnection(template.getDataSource()); + Connection connection = template.getConnection(); if (connection == null) { throw new NullPointerException("There is no current connection"); diff --git a/source/java/org/alfresco/repo/domain/encoding/ibatis/EncodingDAOImpl.java b/source/java/org/alfresco/repo/domain/encoding/ibatis/EncodingDAOImpl.java index 52f4255d23..2c2e465124 100644 --- a/source/java/org/alfresco/repo/domain/encoding/ibatis/EncodingDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/encoding/ibatis/EncodingDAOImpl.java @@ -21,7 +21,7 @@ package org.alfresco.repo.domain.encoding.ibatis; import org.alfresco.repo.domain.encoding.AbstractEncodingDAOImpl; import org.alfresco.repo.domain.encoding.EncodingEntity; import org.alfresco.repo.domain.mimetype.MimetypeEntity; -import org.springframework.orm.ibatis.SqlMapClientTemplate; +import org.mybatis.spring.SqlSessionTemplate; /** * iBatis-specific implementation of the Mimetype DAO. @@ -33,21 +33,23 @@ public class EncodingDAOImpl extends AbstractEncodingDAOImpl { private static final String SELECT_ENCODING_BY_ID = "alfresco.content.select_EncodingById"; private static final String SELECT_ENCODING_BY_KEY = "alfresco.content.select_EncodingByKey"; - private static final String INSERT_ENCODING = "alfresco.content.insert_Encoding"; + private static final String INSERT_ENCODING = "alfresco.content.insert.insert_Encoding"; - private SqlMapClientTemplate template; - - public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) + + private SqlSessionTemplate template; + + public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) { - this.template = sqlMapClientTemplate; + this.template = sqlSessionTemplate; } - + + @Override protected EncodingEntity getEncodingEntity(Long id) { EncodingEntity encodingEntity = new EncodingEntity(); encodingEntity.setId(id); - encodingEntity = (EncodingEntity) template.queryForObject(SELECT_ENCODING_BY_ID, encodingEntity); + encodingEntity = (EncodingEntity) template.selectOne(SELECT_ENCODING_BY_ID, encodingEntity); // Done return encodingEntity; } @@ -57,7 +59,7 @@ public class EncodingDAOImpl extends AbstractEncodingDAOImpl { EncodingEntity encodingEntity = new EncodingEntity(); encodingEntity.setEncoding(encoding == null ? null : encoding.toLowerCase()); - encodingEntity = (EncodingEntity) template.queryForObject(SELECT_ENCODING_BY_KEY, encodingEntity); + encodingEntity = (EncodingEntity) template.selectOne(SELECT_ENCODING_BY_KEY, encodingEntity); // Could be null return encodingEntity; } @@ -68,8 +70,7 @@ public class EncodingDAOImpl extends AbstractEncodingDAOImpl EncodingEntity encodingEntity = new EncodingEntity(); encodingEntity.setVersion(MimetypeEntity.CONST_LONG_ZERO); encodingEntity.setEncoding(encoding == null ? null : encoding.toLowerCase()); - Long id = (Long) template.insert(INSERT_ENCODING, encodingEntity); - encodingEntity.setId(id); + template.insert(INSERT_ENCODING, encodingEntity); // Done return encodingEntity; } diff --git a/source/java/org/alfresco/repo/domain/locale/ibatis/LocaleDAOImpl.java b/source/java/org/alfresco/repo/domain/locale/ibatis/LocaleDAOImpl.java index eff43e6f45..1fe5bbb78c 100644 --- a/source/java/org/alfresco/repo/domain/locale/ibatis/LocaleDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/locale/ibatis/LocaleDAOImpl.java @@ -23,7 +23,7 @@ import java.util.Map; import org.alfresco.repo.domain.locale.AbstractLocaleDAOImpl; import org.alfresco.repo.domain.locale.LocaleEntity; -import org.springframework.orm.ibatis.SqlMapClientTemplate; +import org.mybatis.spring.SqlSessionTemplate; /** * iBatis-specific implementation of the Locale DAO. @@ -35,22 +35,24 @@ public class LocaleDAOImpl extends AbstractLocaleDAOImpl { private static final String SELECT_LOCALE_BY_ID = "alfresco.locale.select_LocaleById"; private static final String SELECT_LOCALE_BY_NAME = "alfresco.locale.select_LocaleByName"; - private static final String INSERT_LOCALE = "alfresco.locale.insert_Locale"; + private static final String INSERT_LOCALE = "alfresco.locale.insert.insert_Locale"; - private SqlMapClientTemplate template; - public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) + private SqlSessionTemplate template; + + public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) { - this.template = sqlMapClientTemplate; + this.template = sqlSessionTemplate; } + @Override protected LocaleEntity getLocaleEntity(Long id) { Map params = new HashMap(1); params.put("id", id); - return (LocaleEntity) template.queryForObject(SELECT_LOCALE_BY_ID, params); + return (LocaleEntity) template.selectOne(SELECT_LOCALE_BY_ID, params); } @Override @@ -59,7 +61,7 @@ public class LocaleDAOImpl extends AbstractLocaleDAOImpl Map params = new HashMap(1); params.put("str", localeStr); - return (LocaleEntity) template.queryForObject(SELECT_LOCALE_BY_NAME, params); + return (LocaleEntity) template.selectOne(SELECT_LOCALE_BY_NAME, params); } @Override @@ -69,8 +71,7 @@ public class LocaleDAOImpl extends AbstractLocaleDAOImpl localeEntity.setVersion(LocaleEntity.CONST_LONG_ZERO); localeEntity.setLocaleStr(localeStr); - Long id = (Long) template.insert(INSERT_LOCALE, localeEntity); - localeEntity.setId(id); + template.insert(INSERT_LOCALE, localeEntity); return localeEntity; } } diff --git a/source/java/org/alfresco/repo/domain/locks/ibatis/LockDAOImpl.java b/source/java/org/alfresco/repo/domain/locks/ibatis/LockDAOImpl.java index edced25fc7..9110a091d6 100644 --- a/source/java/org/alfresco/repo/domain/locks/ibatis/LockDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/locks/ibatis/LockDAOImpl.java @@ -25,7 +25,8 @@ import java.util.Map; import org.alfresco.repo.domain.locks.AbstractLockDAOImpl; import org.alfresco.repo.domain.locks.LockEntity; import org.alfresco.repo.domain.locks.LockResourceEntity; -import org.springframework.orm.ibatis.SqlMapClientTemplate; +import org.mybatis.spring.SqlSessionTemplate; +import org.springframework.dao.ConcurrencyFailureException; /** * iBatis-specific implementation of the Locks DAO. @@ -39,25 +40,27 @@ public class LockDAOImpl extends AbstractLockDAOImpl private static final String SELECT_LOCK_BY_ID = "alfresco.lock.select_LockByID"; private static final String SELECT_LOCK_BY_KEY = "alfresco.lock.select_LockByKey"; private static final String SELECT_LOCK_BY_SHARED_IDS = "alfresco.lock.select_LockBySharedIds"; - private static final String INSERT_LOCKRESOURCE = "alfresco.lock.insert_LockResource"; - private static final String INSERT_LOCK = "alfresco.lock.insert_Lock"; + private static final String INSERT_LOCKRESOURCE = "alfresco.lock.insert.insert_LockResource"; + private static final String INSERT_LOCK = "alfresco.lock.insert.insert_Lock"; private static final String UPDATE_LOCK = "alfresco.lock.update_Lock"; private static final String UPDATE_EXCLUSIVE_LOCK = "alfresco.lock.update_ExclusiveLock"; - private SqlMapClientTemplate template; - - public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) + + private SqlSessionTemplate template; + + public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) { - this.template = sqlMapClientTemplate; + this.template = sqlSessionTemplate; } - + + @Override protected LockResourceEntity getLockResource(Long qnameNamespaceId, String qnameLocalName) { LockResourceEntity lockResource = new LockResourceEntity(); lockResource.setQnameNamespaceId(qnameNamespaceId); lockResource.setQnameLocalName(qnameLocalName == null ? null : qnameLocalName.toLowerCase()); - lockResource = (LockResourceEntity) template.queryForObject(SELECT_LOCKRESOURCE_BY_QNAME, lockResource); + lockResource = (LockResourceEntity) template.selectOne(SELECT_LOCKRESOURCE_BY_QNAME, lockResource); // Could be null return lockResource; } @@ -69,8 +72,7 @@ public class LockDAOImpl extends AbstractLockDAOImpl lockResource.setVersion(LockEntity.CONST_LONG_ZERO); lockResource.setQnameNamespaceId(qnameNamespaceId); lockResource.setQnameLocalName(qnameLocalName == null ? null : qnameLocalName.toLowerCase()); - Long id = (Long) template.insert(INSERT_LOCKRESOURCE, lockResource); - lockResource.setId(id); + template.insert(INSERT_LOCKRESOURCE, lockResource); // Done return lockResource; } @@ -79,7 +81,7 @@ public class LockDAOImpl extends AbstractLockDAOImpl @Override protected List getLocksBySharedResourceIds(List sharedLockResourceIds) { - List locks = template.queryForList(SELECT_LOCK_BY_SHARED_IDS, sharedLockResourceIds); + List locks = (List) template.selectList(SELECT_LOCK_BY_SHARED_IDS, sharedLockResourceIds); // Done return locks; } @@ -89,7 +91,7 @@ public class LockDAOImpl extends AbstractLockDAOImpl { LockEntity lock = new LockEntity(); lock.setId(id); - lock = (LockEntity) template.queryForObject(SELECT_LOCK_BY_ID, lock); + lock = (LockEntity) template.selectOne(SELECT_LOCK_BY_ID, lock); // Done return lock; } @@ -100,7 +102,7 @@ public class LockDAOImpl extends AbstractLockDAOImpl LockEntity lock = new LockEntity(); lock.setSharedResourceId(sharedResourceId); lock.setExclusiveResourceId(exclusiveResourceId); - lock = (LockEntity) template.queryForObject(SELECT_LOCK_BY_KEY, lock); + lock = (LockEntity) template.selectOne(SELECT_LOCK_BY_KEY, lock); // Done return lock; } @@ -121,8 +123,7 @@ public class LockDAOImpl extends AbstractLockDAOImpl long exp = now + timeToLive; lock.setStartTime(now); lock.setExpiryTime(exp); - Long id = (Long) template.insert(INSERT_LOCK, lock); - lock.setId(id); + template.insert(INSERT_LOCK, lock); // Done return lock; } @@ -141,7 +142,14 @@ public class LockDAOImpl extends AbstractLockDAOImpl long exp = (timeToLive > 0) ? (now + timeToLive) : 0L; updateLockEntity.setStartTime(new Long(now)); updateLockEntity.setExpiryTime(new Long(exp)); - template.update(UPDATE_LOCK, updateLockEntity, 1); + + int updated = template.update(UPDATE_LOCK, updateLockEntity); + if (updated != 1) + { + // unexpected number of rows affected + throw new ConcurrencyFailureException("Incorrect number of rows affected for updateLock: " + updateLockEntity + ": expected 1, actual " + updated); + } + // Done return updateLockEntity; } diff --git a/source/java/org/alfresco/repo/domain/mimetype/ibatis/MimetypeDAOImpl.java b/source/java/org/alfresco/repo/domain/mimetype/ibatis/MimetypeDAOImpl.java index 3760003303..95a38aa510 100644 --- a/source/java/org/alfresco/repo/domain/mimetype/ibatis/MimetypeDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/mimetype/ibatis/MimetypeDAOImpl.java @@ -20,8 +20,8 @@ package org.alfresco.repo.domain.mimetype.ibatis; import org.alfresco.repo.domain.mimetype.AbstractMimetypeDAOImpl; import org.alfresco.repo.domain.mimetype.MimetypeEntity; +import org.mybatis.spring.SqlSessionTemplate; import org.springframework.dao.DataIntegrityViolationException; -import org.springframework.orm.ibatis.SqlMapClientTemplate; /** * iBatis-specific implementation of the Mimetype DAO. @@ -33,22 +33,24 @@ public class MimetypeDAOImpl extends AbstractMimetypeDAOImpl { private static final String SELECT_MIMETYPE_BY_ID = "alfresco.content.select_MimetypeById"; private static final String SELECT_MIMETYPE_BY_KEY = "alfresco.content.select_MimetypeByKey"; - private static final String INSERT_MIMETYPE = "alfresco.content.insert_Mimetype"; + private static final String INSERT_MIMETYPE = "alfresco.content.insert.insert_Mimetype"; private static final String UPDATE_MIMETYPE = "alfresco.content.update_Mimetype"; - private SqlMapClientTemplate template; - - public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) + + private SqlSessionTemplate template; + + public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) { - this.template = sqlMapClientTemplate; + this.template = sqlSessionTemplate; } - + + @Override protected MimetypeEntity getMimetypeEntity(Long id) { MimetypeEntity mimetypeEntity = new MimetypeEntity(); mimetypeEntity.setId(id); - mimetypeEntity = (MimetypeEntity) template.queryForObject(SELECT_MIMETYPE_BY_ID, mimetypeEntity); + mimetypeEntity = (MimetypeEntity) template.selectOne(SELECT_MIMETYPE_BY_ID, mimetypeEntity); // Done return mimetypeEntity; } @@ -58,7 +60,7 @@ public class MimetypeDAOImpl extends AbstractMimetypeDAOImpl { MimetypeEntity mimetypeEntity = new MimetypeEntity(); mimetypeEntity.setMimetype(mimetype == null ? null : mimetype.toLowerCase()); - mimetypeEntity = (MimetypeEntity) template.queryForObject(SELECT_MIMETYPE_BY_KEY, mimetypeEntity); + mimetypeEntity = (MimetypeEntity) template.selectOne(SELECT_MIMETYPE_BY_KEY, mimetypeEntity); // Could be null return mimetypeEntity; } @@ -69,8 +71,7 @@ public class MimetypeDAOImpl extends AbstractMimetypeDAOImpl MimetypeEntity mimetypeEntity = new MimetypeEntity(); mimetypeEntity.setVersion(MimetypeEntity.CONST_LONG_ZERO); mimetypeEntity.setMimetype(mimetype == null ? null : mimetype.toLowerCase()); - Long id = (Long) template.insert(INSERT_MIMETYPE, mimetypeEntity); - mimetypeEntity.setId(id); + template.insert(INSERT_MIMETYPE, mimetypeEntity); // Done return mimetypeEntity; } diff --git a/source/java/org/alfresco/repo/domain/node/ibatis/NodeDAOImpl.java b/source/java/org/alfresco/repo/domain/node/ibatis/NodeDAOImpl.java index ed65d4bfca..9017b5d751 100644 --- a/source/java/org/alfresco/repo/domain/node/ibatis/NodeDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/node/ibatis/NodeDAOImpl.java @@ -18,7 +18,6 @@ */ package org.alfresco.repo.domain.node.ibatis; -import java.sql.SQLException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -53,11 +52,12 @@ import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.namespace.QName; import org.alfresco.util.Pair; -import org.springframework.orm.ibatis.SqlMapClientTemplate; +import org.apache.ibatis.session.ResultContext; +import org.apache.ibatis.session.ResultHandler; +import org.apache.ibatis.session.RowBounds; +import org.mybatis.spring.SqlSessionTemplate; import org.springframework.util.Assert; -import com.ibatis.sqlmap.client.event.RowHandler; -import com.sun.star.uno.RuntimeException; /** * iBatis-specific extension of the Node abstract DAO @@ -68,17 +68,17 @@ import com.sun.star.uno.RuntimeException; public class NodeDAOImpl extends AbstractNodeDAOImpl { private static final String SELECT_SERVER_BY_IPADDRESS = "alfresco.node.select_ServerByIpAddress"; - private static final String INSERT_SERVER = "alfresco.node.insert_Server"; - private static final String INSERT_TRANSACTION = "alfresco.node.insert_Transaction"; + private static final String INSERT_SERVER = "alfresco.node.insert.insert_Server"; + private static final String INSERT_TRANSACTION = "alfresco.node.insert.insert_Transaction"; private static final String UPDATE_TRANSACTION_COMMIT_TIME = "alfresco.node.update_TransactionCommitTime"; private static final String DELETE_TRANSACTION_BY_ID = "alfresco.node.delete_TransactionById"; - private static final String INSERT_STORE = "alfresco.node.insert_Store"; + private static final String INSERT_STORE = "alfresco.node.insert.insert_Store"; private static final String UPDATE_STORE_ROOT = "alfresco.node.update_StoreRoot"; private static final String UPDATE_STORE = "alfresco.node.update_Store"; private static final String SELECT_STORE_ALL = "alfresco.node.select_StoreAll"; private static final String SELECT_STORE_ROOT_NODE_BY_ID = "alfresco.node.select_StoreRootNodeById"; private static final String SELECT_STORE_ROOT_NODE_BY_REF = "alfresco.node.select_StoreRootNodeByRef"; - private static final String INSERT_NODE = "alfresco.node.insert_Node"; + private static final String INSERT_NODE = "alfresco.node.insert.insert_Node"; private static final String UPDATE_NODE = "alfresco.node.update_Node"; private static final String UPDATE_NODE_PATCH_ACL = "alfresco.node.update_NodePatchAcl"; private static final String DELETE_NODE_BY_ID = "alfresco.node.delete_NodeById"; @@ -88,20 +88,20 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl private static final String SELECT_NODES_BY_UUIDS = "alfresco.node.select_NodesByUuids"; private static final String SELECT_NODE_PROPERTIES = "alfresco.node.select_NodeProperties"; private static final String SELECT_NODE_ASPECTS = "alfresco.node.select_NodeAspects"; - private static final String INSERT_NODE_PROPERTY = "alfresco.node.insert_NodeProperty"; - private static final String UPDATE_PRIMARY_CHILDREN_SHARED_ACL = "alfresco.node.update_PrimaryChildrenSharedAcl"; - private static final String INSERT_NODE_ASPECT = "alfresco.node.insert_NodeAspect"; + private static final String INSERT_NODE_PROPERTY = "alfresco.node.insert.insert_NodeProperty"; + private static final String UPDATE_PRIMARY_CHILDREN_SHARED_ACL = "alfresco.node.update.update_PrimaryChildrenSharedAcl"; + private static final String INSERT_NODE_ASPECT = "alfresco.node.insert.insert_NodeAspect"; private static final String DELETE_NODE_ASPECTS = "alfresco.node.delete_NodeAspects"; private static final String DELETE_NODE_PROPERTIES = "alfresco.node.delete_NodeProperties"; private static final String SELECT_NODES_WITH_ASPECT_ID = "alfresco.node.select_NodesWithAspectId"; - private static final String INSERT_NODE_ASSOC = "alfresco.node.insert_NodeAssoc"; + private static final String INSERT_NODE_ASSOC = "alfresco.node.insert.insert_NodeAssoc"; private static final String DELETE_NODE_ASSOC = "alfresco.node.delete_NodeAssoc"; private static final String DELETE_NODE_ASSOCS_TO_AND_FROM = "alfresco.node.delete_NodeAssocsToAndFrom"; private static final String SELECT_NODE_ASSOCS_BY_SOURCE = "alfresco.node.select_NodeAssocsBySource"; private static final String SELECT_NODE_ASSOCS_BY_TARGET = "alfresco.node.select_NodeAssocsByTarget"; private static final String SELECT_NODE_ASSOC_BY_ID = "alfresco.node.select_NodeAssocById"; private static final String SELECT_NODE_PRIMARY_CHILD_ACLS = "alfresco.node.select_NodePrimaryChildAcls"; - private static final String INSERT_CHILD_ASSOC = "alfresco.node.insert_ChildAssoc"; + private static final String INSERT_CHILD_ASSOC = "alfresco.node.insert.insert_ChildAssoc"; private static final String DELETE_CHILD_ASSOC_BY_ID = "alfresco.node.delete_ChildAssocById"; private static final String UPDATE_CHILD_ASSOCS_INDEX = "alfresco.node.update_ChildAssocsIndex"; private static final String UPDATE_CHILD_ASSOCS_UNIQUE_NAME = "alfresco.node.update_ChildAssocsUniqueName"; @@ -122,13 +122,14 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl private static final String SELECT_TXN_MIN_COMMIT_TIME = "alfresco.node.select_TxnMinCommitTime"; private static final String SELECT_TXN_MAX_COMMIT_TIME = "alfresco.node.select_TxnMaxCommitTime"; - private SqlMapClientTemplate template; private QNameDAO qnameDAO; private DictionaryService dictionaryService; - public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) + private SqlSessionTemplate template; + + public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) { - this.template = sqlMapClientTemplate; + this.template = sqlSessionTemplate; } @Override @@ -147,6 +148,8 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl public void startBatch() { + // TODO + /* try { template.getSqlMapClient().startBatch(); @@ -155,10 +158,13 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl { throw new RuntimeException("Failed to start DAO batch.", e); } + */ } public void executeBatch() { + // TODO + /* try { template.getSqlMapClient().executeBatch(); @@ -167,6 +173,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl { throw new RuntimeException("Failed to start DAO batch.", e); } + */ } @SuppressWarnings("unchecked") @@ -176,7 +183,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl ServerEntity entity = new ServerEntity(); entity.setIpAddress(ipAddress); // Potentially more results if there is a case issue (unlikely) - List results = template.queryForList(SELECT_SERVER_BY_IPADDRESS, entity); + List results = (List) template.selectList(SELECT_SERVER_BY_IPADDRESS, entity); for (ServerEntity serverEntity : results) { // Take the first one that matches regardless of case @@ -195,7 +202,8 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl ServerEntity entity = new ServerEntity(); entity.setVersion(1L); entity.setIpAddress(ipAddress); - return (Long) template.insert(INSERT_SERVER, entity); + template.insert(INSERT_SERVER, entity); + return entity.getId(); } @Override @@ -208,7 +216,8 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl transaction.setVersion(1L); transaction.setChangeTxnId(changeTxnId); transaction.setCommitTimeMs(commitTimeMs); - return (Long) template.insert(INSERT_TRANSACTION, transaction); + template.insert(INSERT_TRANSACTION, transaction); + return transaction.getId(); } @Override @@ -232,7 +241,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl @Override protected List selectAllStores() { - return template.queryForList(SELECT_STORE_ALL); + return (List) template.selectList(SELECT_STORE_ALL); } @Override @@ -240,7 +249,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl { StoreEntity store = new StoreEntity(); store.setId(storeId); - return (NodeEntity) template.queryForObject(SELECT_STORE_ROOT_NODE_BY_ID, store); + return (NodeEntity) template.selectOne(SELECT_STORE_ROOT_NODE_BY_ID, store); } @Override @@ -249,14 +258,15 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl StoreEntity store = new StoreEntity(); store.setProtocol(storeRef.getProtocol()); store.setIdentifier(storeRef.getIdentifier()); - return (NodeEntity) template.queryForObject(SELECT_STORE_ROOT_NODE_BY_REF, store); + return (NodeEntity) template.selectOne(SELECT_STORE_ROOT_NODE_BY_REF, store); } @Override protected Long insertStore(StoreEntity store) { store.setVersion(1L); - return (Long) template.insert(INSERT_STORE, store); + template.insert(INSERT_STORE, store); + return store.getId(); } @Override @@ -275,7 +285,8 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl protected Long insertNode(NodeEntity node) { node.setVersion(1L); - return (Long) template.insert(INSERT_NODE, node); + template.insert(INSERT_NODE, node); + return node.getId(); } @Override @@ -336,7 +347,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl node.setDeleted(deleted); } - return (NodeEntity) template.queryForObject(SELECT_NODE_BY_ID, node); + return (NodeEntity) template.selectOne(SELECT_NODE_BY_ID, node); } @Override @@ -363,7 +374,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl node.setDeleted(deleted); } - return (NodeEntity) template.queryForObject(SELECT_NODE_BY_NODEREF, node); + return (NodeEntity) template.selectOne(SELECT_NODE_BY_NODEREF, node); } @SuppressWarnings("unchecked") @@ -374,7 +385,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl nodeBatchLoadEntity.setStoreId(storeId); nodeBatchLoadEntity.setUuids(new ArrayList(uuids)); - return (List) template.queryForList(SELECT_NODES_BY_UUIDS, nodeBatchLoadEntity); + return (List) template.selectList(SELECT_NODES_BY_UUIDS, nodeBatchLoadEntity); } /** @@ -431,7 +442,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl NodeAspectsEntity aspects = new NodeAspectsEntity(); aspects.setNodeIds(new ArrayList(nodeIds)); - List rows = template.queryForList(SELECT_NODE_ASPECTS, aspects); + List rows = (List) template.selectList(SELECT_NODE_ASPECTS, aspects); return rows; } @@ -446,7 +457,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl NodePropertyEntity prop = new NodePropertyEntity(); prop.setNodeIds(new ArrayList(nodeIds)); - List rows = template.queryForList(SELECT_NODE_PROPERTIES, prop); + List rows = (List) template.selectList(SELECT_NODE_PROPERTIES, prop); return makePersistentPropertiesMap(rows); } @Override @@ -475,7 +486,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl prop.setQnameIds(new ArrayList(qnameIds)); } - List rows = template.queryForList(SELECT_NODE_PROPERTIES, prop); + List rows = (List) template.selectList(SELECT_NODE_PROPERTIES, prop); Map> results = makePersistentPropertiesMap(rows); Map props = results.get(nodeId); if (props == null) @@ -602,11 +613,11 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl @Override protected void selectNodesWithAspect(Long qnameId, Long minNodeId, final NodeRefQueryCallback resultsCallback) { - RowHandler rowHandler = new RowHandler() + ResultHandler resultHandler = new ResultHandler() { - public void handleRow(Object valueObject) + public void handleResult(ResultContext context) { - NodeEntity entity = (NodeEntity) valueObject; + NodeEntity entity = (NodeEntity) context.getResultObject(); Pair nodePair = new Pair(entity.getId(), entity.getNodeRef()); resultsCallback.handle(nodePair); } @@ -615,7 +626,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl Map parameters = new HashMap(5); parameters.put("minNodeId", minNodeId); parameters.put("qnameId", qnameId); - template.queryWithRowHandler(SELECT_NODES_WITH_ASPECT_ID, parameters,rowHandler); + template.select(SELECT_NODES_WITH_ASPECT_ID, parameters,resultHandler); } @Override @@ -633,7 +644,8 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl targetNode.setId(targetNodeId); assoc.setTargetNode(targetNode); - return (Long) template.insert(INSERT_NODE_ASSOC, assoc); + template.insert(INSERT_NODE_ASSOC, assoc); + return assoc.getId(); } @Override @@ -696,7 +708,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl sourceNode.setId(sourceNodeId); assoc.setSourceNode(sourceNode); - return (List) template.queryForList(SELECT_NODE_ASSOCS_BY_SOURCE, assoc); + return (List) template.selectList(SELECT_NODE_ASSOCS_BY_SOURCE, assoc); } @SuppressWarnings("unchecked") @@ -709,7 +721,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl targetNode.setId(targetNodeId); assoc.setTargetNode(targetNode); - return (List) template.queryForList(SELECT_NODE_ASSOCS_BY_TARGET, assoc); + return (List) template.selectList(SELECT_NODE_ASSOCS_BY_TARGET, assoc); } @Override @@ -718,14 +730,15 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl NodeAssocEntity assoc = new NodeAssocEntity(); assoc.setId(assocId); - return (NodeAssocEntity) template.queryForObject(SELECT_NODE_ASSOC_BY_ID, assoc); + return (NodeAssocEntity) template.selectOne(SELECT_NODE_ASSOC_BY_ID, assoc); } @Override protected Long insertChildAssoc(ChildAssocEntity assoc) { assoc.setVersion(1L); - return (Long) template.insert(INSERT_CHILD_ASSOC, assoc); + template.insert(INSERT_CHILD_ASSOC, assoc); + return assoc.getId(); } @Override @@ -801,7 +814,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl ChildAssocEntity assoc = new ChildAssocEntity(); assoc.setId(assocId); - return (ChildAssocEntity) template.queryForObject(SELECT_CHILD_ASSOC_BY_ID, assoc); + return (ChildAssocEntity) template.selectOne(SELECT_CHILD_ASSOC_BY_ID, assoc); } @SuppressWarnings("unchecked") @@ -816,7 +829,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl // Primary assoc.setPrimary(true); - return template.queryForList(SELECT_NODE_PRIMARY_CHILD_ACLS, assoc); + return (List) template.selectList(SELECT_NODE_PRIMARY_CHILD_ACLS, assoc); } @SuppressWarnings("unchecked") @@ -847,16 +860,16 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl return Collections.emptyList(); // Shortcut } - return template.queryForList(SELECT_CHILD_ASSOCS_OF_PARENT, assoc); + return (List) template.selectList(SELECT_CHILD_ASSOCS_OF_PARENT, assoc); } /** - * Filter to allow the {@link ChildAssocRowHandler} to filter results. + * Filter to allow the {@link ChildAssocResultHandler} to filter results. * * @author Derek Hulley * @since 3.4 */ - private interface ChildAssocRowHandlerFilter + private interface ChildAssocResultHandlerFilter { boolean isResult(ChildAssocEntity assoc); } @@ -867,24 +880,24 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl * @author Derek Hulley * @since 3.4 */ - private class ChildAssocRowHandler implements RowHandler + private class ChildAssocResultHandler implements ResultHandler { - private final ChildAssocRowHandlerFilter filter; + private final ChildAssocResultHandlerFilter filter; private final ChildAssocRefQueryCallback resultsCallback; private boolean more = true; - private ChildAssocRowHandler(ChildAssocRefQueryCallback resultsCallback) + private ChildAssocResultHandler(ChildAssocRefQueryCallback resultsCallback) { this(null, resultsCallback); } - private ChildAssocRowHandler(ChildAssocRowHandlerFilter filter, ChildAssocRefQueryCallback resultsCallback) + private ChildAssocResultHandler(ChildAssocResultHandlerFilter filter, ChildAssocRefQueryCallback resultsCallback) { this.filter = filter; this.resultsCallback = resultsCallback; } - public void handleRow(Object valueObject) + public void handleResult(ResultContext context) { // Do nothing if no further results are required // TODO: Use iBatis' new feature (when we upgrade) to kill the resultset walking @@ -892,7 +905,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl { return; } - ChildAssocEntity assoc = (ChildAssocEntity) valueObject; + ChildAssocEntity assoc = (ChildAssocEntity) context.getResultObject(); if (filter != null && !filter.isResult(assoc)) { // Filtered out @@ -959,8 +972,12 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl assoc.setSameStore(sameStore); } - ChildAssocRowHandler rowHandler = new ChildAssocRowHandler(resultsCallback); - template.queryWithRowHandler(SELECT_CHILD_ASSOCS_OF_PARENT, assoc, rowHandler); + ChildAssocResultHandler resultHandler = new ChildAssocResultHandler(resultsCallback); + + // TODO MyBatis workaround - see also http://code.google.com/p/mybatis/issues/detail?id=58 (and #139, #234, ...) + template.clearCache(); + template.select(SELECT_CHILD_ASSOCS_OF_PARENT, assoc, resultHandler); + resultsCallback.done(); } @@ -983,8 +1000,12 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl } assoc.setTypeQNameIds(new ArrayList(assocTypeQNameIds)); - ChildAssocRowHandler rowHandler = new ChildAssocRowHandler(resultsCallback); - template.queryWithRowHandler(SELECT_CHILD_ASSOCS_OF_PARENT, assoc, rowHandler); + ChildAssocResultHandler resultHandler = new ChildAssocResultHandler(resultsCallback); + + // TODO MyBatis workaround - see also http://code.google.com/p/mybatis/issues/detail?id=58 (and #139, #234, ...) + template.clearCache(); + template.select(SELECT_CHILD_ASSOCS_OF_PARENT, assoc, resultHandler); + resultsCallback.done(); } @@ -1005,7 +1026,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl assoc.setChildNodeNameAll(null, assocTypeQName, childName); // Note: This single results was assumed from inception of the original method. It's correct. - return (ChildAssocEntity) template.queryForObject(SELECT_CHILD_ASSOCS_OF_PARENT, assoc); + return (ChildAssocEntity) template.selectOne(SELECT_CHILD_ASSOCS_OF_PARENT, assoc); } @Override @@ -1035,7 +1056,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl childNamesCrc.add(childNameCrc); } // Create a filter that checks that the name CRC is present - ChildAssocRowHandlerFilter filter = new ChildAssocRowHandlerFilter() + ChildAssocResultHandlerFilter filter = new ChildAssocResultHandlerFilter() { public boolean isResult(ChildAssocEntity assoc) { @@ -1059,8 +1080,12 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl // Child names assoc.setChildNodeNameCrcs(childNamesCrc); - ChildAssocRowHandler rowHandler = new ChildAssocRowHandler(filter, resultsCallback); - template.queryWithRowHandler(SELECT_CHILD_ASSOCS_OF_PARENT, assoc, rowHandler); + ChildAssocResultHandler resultHandler = new ChildAssocResultHandler(filter, resultsCallback); + + // TODO MyBatis workaround - see also http://code.google.com/p/mybatis/issues/detail?id=58 (and #139, #234, ...) + template.clearCache(); + template.select(SELECT_CHILD_ASSOCS_OF_PARENT, assoc, resultHandler); + resultsCallback.done(); } @@ -1083,8 +1108,8 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl } assoc.setChildNodeTypeQNameIds(new ArrayList(childNodeTypeQNameIds)); - ChildAssocRowHandler rowHandler = new ChildAssocRowHandler(resultsCallback); - template.queryWithRowHandler(SELECT_CHILD_ASSOCS_OF_PARENT, assoc, rowHandler); + ChildAssocResultHandler resultHandler = new ChildAssocResultHandler(resultsCallback); + template.select(SELECT_CHILD_ASSOCS_OF_PARENT, assoc, resultHandler); resultsCallback.done(); } @@ -1105,8 +1130,8 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl return; // Shortcut } - ChildAssocRowHandler rowHandler = new ChildAssocRowHandler(resultsCallback); - template.queryWithRowHandler(SELECT_CHILD_ASSOCS_OF_PARENT_WITHOUT_PARENT_ASSOCS_OF_TYPE, assoc, rowHandler); + ChildAssocResultHandler resultHandler = new ChildAssocResultHandler(resultsCallback); + template.select(SELECT_CHILD_ASSOCS_OF_PARENT_WITHOUT_PARENT_ASSOCS_OF_TYPE, assoc, resultHandler); resultsCallback.done(); } @@ -1122,7 +1147,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl // Primary assoc.setPrimary(Boolean.TRUE); - return template.queryForList(SELECT_PARENT_ASSOCS_OF_CHILD, assoc); + return (List) template.selectList(SELECT_PARENT_ASSOCS_OF_CHILD, assoc); } @Override @@ -1160,8 +1185,12 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl assoc.setPrimary(isPrimary); } - ChildAssocRowHandler rowHandler = new ChildAssocRowHandler(resultsCallback); - template.queryWithRowHandler(SELECT_PARENT_ASSOCS_OF_CHILD, assoc, rowHandler); + ChildAssocResultHandler resultHandler = new ChildAssocResultHandler(resultsCallback); + + // TODO MyBatis workaround - see also http://code.google.com/p/mybatis/issues/detail?id=58 (and #139, #234, ...) + template.clearCache(); + template.select(SELECT_PARENT_ASSOCS_OF_CHILD, assoc, resultHandler); + resultsCallback.done(); } @@ -1175,7 +1204,9 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl childNode.setId(childNodeId); assoc.setChildNode(childNode); - return template.queryForList(SELECT_PARENT_ASSOCS_OF_CHILD, assoc); + // TODO MyBatis workaround - see also http://code.google.com/p/mybatis/issues/detail?id=58 (and #139, #234, ...) + template.clearCache(); + return (List) template.selectList(SELECT_PARENT_ASSOCS_OF_CHILD, assoc); } @Override @@ -1222,7 +1253,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl TransactionQueryEntity query = new TransactionQueryEntity(); query.setMaxCommitTime(maxCommitTime); - List txns = template.queryForList(SELECT_TXN_LAST, query, 0, 1); + List txns = (List) template.selectList(SELECT_TXN_LAST, query, new RowBounds(0, 1)); if (txns.size() > 0) { return txns.get(0); @@ -1236,7 +1267,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl @Override protected int selectTransactionCount() { - return (Integer) template.queryForObject(SELECT_TXN_COUNT); + return (Integer) template.selectOne(SELECT_TXN_COUNT); } @Override @@ -1245,7 +1276,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl TransactionQueryEntity query = new TransactionQueryEntity(); query.setId(txnId); - return (Transaction) template.queryForObject(SELECT_TXNS, query); + return (Transaction) template.selectOne(SELECT_TXNS, query); } @SuppressWarnings("unchecked") @@ -1260,7 +1291,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl } // TODO: Return List for quicker node_deleted access - return (List) template.queryForList(SELECT_TXN_NODES, query); + return (List) template.selectList(SELECT_TXN_NODES, query); } @Override @@ -1277,7 +1308,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl transaction.setId(txnId); node.setTransaction(transaction); - return (Integer) template.queryForObject(SELECT_TXN_NODE_COUNT, node); + return (Integer) template.selectOne(SELECT_TXN_NODE_COUNT, node); } @SuppressWarnings("unchecked") @@ -1294,18 +1325,27 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl TransactionQueryEntity query = new TransactionQueryEntity(); query.setMinCommitTime(fromTimeInclusive); query.setMaxCommitTime(toTimeExclusive); - query.setIncludeTxnIds(includeTxnIds); - query.setExcludeTxnIds(excludeTxnIds); + + if ((includeTxnIds != null) && (includeTxnIds.size() > 0)) + { + query.setIncludeTxnIds(includeTxnIds); + } + + if ((excludeTxnIds != null) && (excludeTxnIds.size() > 0)) + { + query.setExcludeTxnIds(excludeTxnIds); + } + query.setExcludeServerId(excludeServerId); query.setAscending(ascending); if (count == null) { - return template.queryForList(SELECT_TXNS, query); + return (List) template.selectList(SELECT_TXNS, query); } else { - return template.queryForList(SELECT_TXNS, query, 0, count); + return (List) template.selectList(SELECT_TXNS, query, new RowBounds(0, count)); } } @@ -1318,24 +1358,24 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl query.setMaxCommitTime(maxCommitTime); if (count == null) { - return template.queryForList(SELECT_TXNS_UNUSED, query); + return (List) template.selectList(SELECT_TXNS_UNUSED, query); } else { - return template.queryForList(SELECT_TXNS_UNUSED, query, 0, count); + return (List) template.selectList(SELECT_TXNS_UNUSED, query, new RowBounds(0, count)); } } @Override protected Long selectMinTxnCommitTime() { - return (Long) template.queryForObject(SELECT_TXN_MIN_COMMIT_TIME); + return (Long) template.selectOne(SELECT_TXN_MIN_COMMIT_TIME); } @Override protected Long selectMaxTxnCommitTime() { - return (Long) template.queryForObject(SELECT_TXN_MAX_COMMIT_TIME); + return (Long) template.selectOne(SELECT_TXN_MAX_COMMIT_TIME); } @Override @@ -1358,8 +1398,8 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl assocProp.setValue(nodeValue); assocProp.setPropertyQNameId(propName.getFirst()); - ChildAssocRowHandler rowHandler = new ChildAssocRowHandler(resultsCallback); - template.queryWithRowHandler(SELECT_CHILD_ASSOCS_BY_PROPERTY_VALUE, assocProp, rowHandler); + ChildAssocResultHandler resultHandler = new ChildAssocResultHandler(resultsCallback); + template.select(SELECT_CHILD_ASSOCS_BY_PROPERTY_VALUE, assocProp, resultHandler); resultsCallback.done(); } } diff --git a/source/java/org/alfresco/repo/domain/patch/AbstractPatchDAOImpl.java b/source/java/org/alfresco/repo/domain/patch/AbstractPatchDAOImpl.java index 11f98c2d78..db0324691d 100644 --- a/source/java/org/alfresco/repo/domain/patch/AbstractPatchDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/patch/AbstractPatchDAOImpl.java @@ -25,8 +25,7 @@ import org.alfresco.ibatis.BatchingDAO; import org.alfresco.repo.domain.avm.AVMNodeEntity; import org.alfresco.repo.domain.contentdata.ContentDataDAO; import org.alfresco.service.cmr.repository.ContentData; - -import com.ibatis.sqlmap.client.event.RowHandler; +import org.apache.ibatis.session.ResultHandler; /** @@ -218,36 +217,36 @@ public abstract class AbstractPatchDAOImpl implements PatchDAO, BatchingDAO protected abstract int deleteAclMemberEntitiesForAcls(List aclIds); // note: caller's row handler is expected to migrate the attrs - public void migrateOldAttrTenants(RowHandler rowHandler) + public void migrateOldAttrTenants(ResultHandler resultHandler) { - getOldAttrTenantsImpl(rowHandler); + getOldAttrTenantsImpl(resultHandler); } - protected abstract void getOldAttrTenantsImpl(RowHandler rowHandler); + protected abstract void getOldAttrTenantsImpl(ResultHandler resultHandler); // note: caller's row handler is expected to migrate the attrs - public void migrateOldAttrAVMLocks(RowHandler rowHandler) + public void migrateOldAttrAVMLocks(ResultHandler resultHandler) { - getOldAttrAVMLocksImpl(rowHandler); + getOldAttrAVMLocksImpl(resultHandler); } - protected abstract void getOldAttrAVMLocksImpl(RowHandler rowHandler); + protected abstract void getOldAttrAVMLocksImpl(ResultHandler resultHandler); // note: caller's row handler is expected to migrate the attrs - public void migrateOldAttrPropertyBackedBeans(RowHandler rowHandler) + public void migrateOldAttrPropertyBackedBeans(ResultHandler resultHandler) { - getOldAttrPropertyBackedBeansImpl(rowHandler); + getOldAttrPropertyBackedBeansImpl(resultHandler); } - protected abstract void getOldAttrPropertyBackedBeansImpl(RowHandler rowHandler); + protected abstract void getOldAttrPropertyBackedBeansImpl(ResultHandler resultHandler); // note: caller's row handler is expected to migrate the attrs - public void migrateOldAttrChainingURS(RowHandler rowHandler) + public void migrateOldAttrChainingURS(ResultHandler resultHandler) { - getOldAttrChainingURSImpl(rowHandler); + getOldAttrChainingURSImpl(resultHandler); } - protected abstract void getOldAttrChainingURSImpl(RowHandler rowHandler); + protected abstract void getOldAttrChainingURSImpl(ResultHandler resultHandler); public List getOldAttrCustomNames() { diff --git a/source/java/org/alfresco/repo/domain/patch/PatchDAO.java b/source/java/org/alfresco/repo/domain/patch/PatchDAO.java index f3ddc37511..ac4860630c 100644 --- a/source/java/org/alfresco/repo/domain/patch/PatchDAO.java +++ b/source/java/org/alfresco/repo/domain/patch/PatchDAO.java @@ -27,8 +27,7 @@ import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; import org.alfresco.util.Pair; - -import com.ibatis.sqlmap.client.event.RowHandler; +import org.apache.ibatis.session.ResultHandler; /** * Additional DAO services for patches @@ -187,22 +186,22 @@ public interface PatchDAO /** * Migrate old Tenant attributes (if any) */ - public void migrateOldAttrTenants(RowHandler rowHandler); + public void migrateOldAttrTenants(ResultHandler resultHandler); /** * Migrate old AVM Lock attributes (if any) */ - public void migrateOldAttrAVMLocks(RowHandler rowHandler); + public void migrateOldAttrAVMLocks(ResultHandler resultHandler); /** * Migrate old Property-Backed Bean attributes (if any) */ - public void migrateOldAttrPropertyBackedBeans(RowHandler rowHandler); + public void migrateOldAttrPropertyBackedBeans(ResultHandler resultHandler); /** * Migrate old Chaining User Registry Synchronizer attributes (if any) */ - public void migrateOldAttrChainingURS(RowHandler rowHandler); + public void migrateOldAttrChainingURS(ResultHandler resultHandler); /** * Get custom global attribute names (if any) diff --git a/source/java/org/alfresco/repo/domain/patch/ibatis/AppliedPatchDAOImpl.java b/source/java/org/alfresco/repo/domain/patch/ibatis/AppliedPatchDAOImpl.java index efe992cef0..82857927dd 100644 --- a/source/java/org/alfresco/repo/domain/patch/ibatis/AppliedPatchDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/patch/ibatis/AppliedPatchDAOImpl.java @@ -22,7 +22,7 @@ import java.util.List; import org.alfresco.repo.domain.patch.AbstractAppliedPatchDAOImpl; import org.alfresco.repo.domain.patch.AppliedPatchEntity; -import org.springframework.orm.ibatis.SqlMapClientTemplate; +import org.mybatis.spring.SqlSessionTemplate; /** * iBatis-specific implementation of the AppliedPatch DAO. @@ -37,13 +37,15 @@ public class AppliedPatchDAOImpl extends AbstractAppliedPatchDAOImpl private static final String SELECT_APPLIED_PATCH_BY_ID = "alfresco.appliedpatch.select_AppliedPatchById"; private static final String SELECT_ALL_APPLIED_PATCH = "alfresco.appliedpatch.select_AllAppliedPatches"; - private SqlMapClientTemplate template; - - public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) + + private SqlSessionTemplate template; + + public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) { - this.template = sqlMapClientTemplate; + this.template = sqlSessionTemplate; } - + + @Override protected void createAppliedPatchEntity(AppliedPatchEntity entity) { @@ -60,7 +62,7 @@ public class AppliedPatchDAOImpl extends AbstractAppliedPatchDAOImpl { AppliedPatchEntity entity = new AppliedPatchEntity(); entity.setId(id); - entity = (AppliedPatchEntity) template.queryForObject(SELECT_APPLIED_PATCH_BY_ID, entity); + entity = (AppliedPatchEntity) template.selectOne(SELECT_APPLIED_PATCH_BY_ID, entity); // Could be null return entity; } @@ -69,9 +71,8 @@ public class AppliedPatchDAOImpl extends AbstractAppliedPatchDAOImpl @Override protected List getAppliedPatchEntities() { - return (List) template.queryForList(SELECT_ALL_APPLIED_PATCH); + return (List) template.selectList(SELECT_ALL_APPLIED_PATCH); } - // // @Override diff --git a/source/java/org/alfresco/repo/domain/patch/ibatis/PatchDAOImpl.java b/source/java/org/alfresco/repo/domain/patch/ibatis/PatchDAOImpl.java index b5851819e0..9139e58359 100644 --- a/source/java/org/alfresco/repo/domain/patch/ibatis/PatchDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/patch/ibatis/PatchDAOImpl.java @@ -18,7 +18,6 @@ */ package org.alfresco.repo.domain.patch.ibatis; -import java.sql.SQLException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -39,10 +38,10 @@ import org.alfresco.util.Pair; import org.alfresco.util.ParameterCheck; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.orm.ibatis.SqlMapClientTemplate; - -import com.ibatis.sqlmap.client.event.RowHandler; -import com.ibatis.sqlmap.engine.execution.SqlExecutor; +import org.apache.ibatis.session.ResultContext; +import org.apache.ibatis.session.ResultHandler; +import org.apache.ibatis.session.RowBounds; +import org.mybatis.spring.SqlSessionTemplate; /** * iBatis-specific implementation of the AVMPatch DAO. @@ -101,15 +100,18 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl private static final String SELECT_SHARED_ACLS_THAT_DO_NOT_INHERIT_CORRECTLY_FROM_THE_PRIMARY_PARENT = "alfresco.patch.select_sharedAclsThatDoNotInheritCorrectlyFromThePrimaryParent"; private static final String SELECT_SHARED_ACLS_THAT_DO_NOT_INHERIT_CORRECTLY_FROM_THEIR_DEFINING_ACL = "alfresco.patch.select_sharedAclsThatDoNotInheritCorrectlyFromTheirDefiningAcl"; - private SqlMapClientTemplate template; - private QNameDAO qnameDAO; private LocaleDAO localeDAO; - public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) + private SqlSessionTemplate template; + + public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) { - this.template = sqlMapClientTemplate; + this.template = sqlSessionTemplate; } + + private QNameDAO qnameDAO; + public void setQnameDAO(QNameDAO qnameDAO) { this.qnameDAO = qnameDAO; @@ -122,6 +124,8 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl public void startBatch() { + // TODO + /* try { template.getSqlMapClient().startBatch(); @@ -130,10 +134,13 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl { throw new RuntimeException("Failed to start batch", e); } + */ } public void executeBatch() { + // TODO + /* try { template.getSqlMapClient().executeBatch(); @@ -142,12 +149,13 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl { throw new RuntimeException("Failed to start batch", e); } + */ } @Override protected long getAVMNodeEntitiesCountWhereNewInStore() { - Long count = (Long) template.queryForObject(SELECT_AVM_NODE_ENTITIES_COUNT_WHERE_NEW_IN_STORE); + Long count = (Long) template.selectOne(SELECT_AVM_NODE_ENTITIES_COUNT_WHERE_NEW_IN_STORE); return count == null ? 0L : count; } @@ -157,10 +165,10 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl { if (maxResults < 0) { - maxResults = SqlExecutor.NO_MAXIMUM_RESULTS; + maxResults = RowBounds.NO_ROW_LIMIT; } - return (List) template.queryForList(SELECT_AVM_NODE_ENTITIES_WITH_EMPTY_GUID, 0, maxResults); + return (List) template.selectList(SELECT_AVM_NODE_ENTITIES_WITH_EMPTY_GUID, new RowBounds(0, maxResults)); } @SuppressWarnings("unchecked") @@ -169,10 +177,10 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl { if (maxResults < 0) { - maxResults = SqlExecutor.NO_MAXIMUM_RESULTS; + maxResults = RowBounds.NO_ROW_LIMIT; } - return (List) template.queryForList(SELECT_AVM_LD_NODE_ENTITIES_NULL_VERSION, 0, maxResults); + return (List) template.selectList(SELECT_AVM_LD_NODE_ENTITIES_NULL_VERSION, new RowBounds(0, maxResults)); } @SuppressWarnings("unchecked") @@ -181,15 +189,15 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl { if (maxResults < 0) { - maxResults = SqlExecutor.NO_MAXIMUM_RESULTS; + maxResults = RowBounds.NO_ROW_LIMIT; } - return (List) template.queryForList(SELECT_AVM_LF_NODE_ENTITIES_NULL_VERSION, 0, maxResults); + return (List) template.selectList(SELECT_AVM_LF_NODE_ENTITIES_NULL_VERSION, new RowBounds(0, maxResults)); } public long getMaxAvmNodeID() { - Long count = (Long) template.queryForObject(SELECT_AVM_MAX_NODE_ID); + Long count = (Long) template.selectOne(SELECT_AVM_MAX_NODE_ID); return count == null ? 0L : count; } @@ -199,12 +207,12 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl IdsEntity ids = new IdsEntity(); ids.setIdOne(minNodeId); ids.setIdTwo(maxNodeId); - return (List) template.queryForList(SELECT_AVM_NODES_WITH_OLD_CONTENT_PROPERTIES, ids); + return (List) template.selectList(SELECT_AVM_NODES_WITH_OLD_CONTENT_PROPERTIES, ids); } public long getMaxAdmNodeID() { - Long count = (Long) template.queryForObject(SELECT_ADM_MAX_NODE_ID); + Long count = (Long) template.selectOne(SELECT_ADM_MAX_NODE_ID); return count == null ? 0L : count; } @@ -215,7 +223,7 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl IdsEntity ids = new IdsEntity(); ids.setIdOne(minNodeId); ids.setIdTwo(maxNodeId); - return (List>) template.queryForList(SELECT_ADM_OLD_CONTENT_PROPERTIES, ids); + return (List>) template.selectList(SELECT_ADM_OLD_CONTENT_PROPERTIES, ids); } @Override @@ -277,14 +285,14 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl @Override protected long getMaxAclEntityId() { - Long count = (Long) template.queryForObject(SELECT_PERMISSIONS_MAX_ACL_ID, null); + Long count = (Long) template.selectOne(SELECT_PERMISSIONS_MAX_ACL_ID, null); return count == null ? 0L : count; } @Override protected long getDmNodeEntitiesCount() { - Long count = (Long) template.queryForObject(SELECT_PERMISSIONS_DM_NODE_COUNT, null); + Long count = (Long) template.selectOne(SELECT_PERMISSIONS_DM_NODE_COUNT, null); return count == null ? 0L : count; } @@ -293,7 +301,7 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl { Map params = new HashMap(1); params.put("id", above); - Long count = (Long) template.queryForObject(SELECT_PERMISSIONS_DM_NODE_COUNT_WITH_NEW_ACLS, params); + Long count = (Long) template.selectOne(SELECT_PERMISSIONS_DM_NODE_COUNT_WITH_NEW_ACLS, params); return count == null ? 0L : count; } @@ -301,14 +309,14 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl @Override protected List selectAllAclEntityIds() { - return (List) template.queryForList(SELECT_PERMISSIONS_ALL_ACL_IDS); + return (List) template.selectList(SELECT_PERMISSIONS_ALL_ACL_IDS); } @SuppressWarnings("unchecked") @Override protected List selectNonDanglingAclEntityIds() { - return (List) template.queryForList(SELECT_PERMISSIONS_USED_ACL_IDS); + return (List) template.selectList(SELECT_PERMISSIONS_USED_ACL_IDS); } @Override @@ -332,12 +340,12 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl public List getAuthoritiesWithNonUtf8Crcs() { final List results = new ArrayList(1000); - RowHandler rowHandler = new RowHandler() + ResultHandler resultHandler = new ResultHandler() { @SuppressWarnings("unchecked") - public void handleRow(Object valueObject) + public void handleResult(ResultContext context) { - Map result = (Map) valueObject; + Map result = (Map) context.getResultObject(); String authority = (String) result.get("authority"); Long crc = (Long) result.get("crc"); Long crcShouldBe = CrcHelper.getStringCrcPair(authority, 32, true, true).getSecond(); @@ -348,20 +356,20 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl } } }; - template.queryWithRowHandler(SELECT_AUTHORITIES_AND_CRC, rowHandler); + template.select(SELECT_AUTHORITIES_AND_CRC, resultHandler); // Done return results; } public int getChildAssocCount() { - return (Integer) template.queryForObject(SELECT_CHILD_ASSOCS_COUNT); + return (Integer) template.selectOne(SELECT_CHILD_ASSOCS_COUNT); } @Override public Long getMaxChildAssocId() { - Long maxAssocId = (Long) template.queryForObject(SELECT_CHILD_ASSOCS_MAX_ID); + Long maxAssocId = (Long) template.selectOne(SELECT_CHILD_ASSOCS_MAX_ID); return maxAssocId == null ? 0L : maxAssocId; } @@ -400,7 +408,7 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl try { - List> rows = template.queryForList(SELECT_CHILD_ASSOCS_FOR_CRCS, entity, 0, queryMaxResults); + List> rows = (List>) template.selectList(SELECT_CHILD_ASSOCS_FOR_CRCS, entity, new RowBounds(0, queryMaxResults)); if (results.size() == 0 && rows.size() >= maxResults) { // We have all we need @@ -473,12 +481,12 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl params.put("namePattern", namePattern); final List> results = new ArrayList>(500); - RowHandler rowHandler = new RowHandler() + ResultHandler resultHandler = new ResultHandler() { @SuppressWarnings("unchecked") - public void handleRow(Object rowObject) + public void handleResult(ResultContext context) { - Map row = (Map) rowObject; + Map row = (Map) context.getResultObject(); String protocol = (String) row.get("protocol"); String identifier = (String) row.get("identifier"); String uuid = (String) row.get("uuid"); @@ -488,39 +496,39 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl results.add(pair); } }; - template.queryWithRowHandler(SELECT_NODES_BY_TYPE_AND_NAME_PATTERN, params, rowHandler); + template.select(SELECT_NODES_BY_TYPE_AND_NAME_PATTERN, params, resultHandler); return results; } @Override - protected void getOldAttrTenantsImpl(RowHandler rowHandler) + protected void getOldAttrTenantsImpl(ResultHandler resultHandler) { - template.queryWithRowHandler(SELECT_OLD_ATTR_TENANTS, rowHandler); + template.select(SELECT_OLD_ATTR_TENANTS, resultHandler); } @Override - protected void getOldAttrAVMLocksImpl(RowHandler rowHandler) + protected void getOldAttrAVMLocksImpl(ResultHandler resultHandler) { - template.queryWithRowHandler(SELECT_OLD_ATTR_AVM_LOCKS, rowHandler); + template.select(SELECT_OLD_ATTR_AVM_LOCKS, resultHandler); } @Override - protected void getOldAttrPropertyBackedBeansImpl(RowHandler rowHandler) + protected void getOldAttrPropertyBackedBeansImpl(ResultHandler resultHandler) { - template.queryWithRowHandler(SELECT_OLD_ATTR_PBBS, rowHandler); + template.select(SELECT_OLD_ATTR_PBBS, resultHandler); } @Override - protected void getOldAttrChainingURSImpl(RowHandler rowHandler) + protected void getOldAttrChainingURSImpl(ResultHandler resultHandler) { - template.queryWithRowHandler(SELECT_OLD_ATTR_CHAINING_URS, rowHandler); + template.select(SELECT_OLD_ATTR_CHAINING_URS, resultHandler); } @SuppressWarnings("unchecked") @Override protected List getOldAttrCustomNamesImpl() { - return (List)template.queryForList(SELECT_OLD_ATTR_CUSTOM_NAMES); + return (List)template.selectList(SELECT_OLD_ATTR_CUSTOM_NAMES); } @Override @@ -545,7 +553,7 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl @Override public List> getAclsThatInheritFromNonPrimaryParent() { - List> rows = template.queryForList( + List> rows = (List>) template.selectList( SELECT_ACLS_THAT_INHERIT_FROM_NON_PRIMARY_PARENT, Boolean.TRUE); return rows; @@ -555,7 +563,7 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl @Override public List> getAclsThatInheritWithInheritanceUnset() { - List> rows = template.queryForList( + List> rows = (List>) template.selectList( SELECT_ACLS_THAT_INHERIT_WITH_INHERITANCE_UNSET, Boolean.TRUE); return rows; @@ -565,7 +573,7 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl @Override public List> getDefiningAclsThatDoNotInheritCorrectlyFromThePrimaryParent() { - List> rows = template.queryForList( + List> rows = (List>) template.selectList( SELECT_DEFINING_ACLS_THAT_DO_NOT_INHERIT_CORRECTLY_FROM_THE_PRIMARY_PARENT, Boolean.TRUE); return rows; @@ -575,7 +583,7 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl @Override public List> getSharedAclsThatDoNotInheritCorrectlyFromThePrimaryParent() { - List> rows = template.queryForList( + List> rows = (List>) template.selectList( SELECT_SHARED_ACLS_THAT_DO_NOT_INHERIT_CORRECTLY_FROM_THE_PRIMARY_PARENT, Boolean.TRUE); return rows; @@ -585,7 +593,7 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl @Override public List> getSharedAclsThatDoNotInheritCorrectlyFromTheirDefiningAcl() { - List> rows = template.queryForList( + List> rows = (List>) template.selectList( SELECT_SHARED_ACLS_THAT_DO_NOT_INHERIT_CORRECTLY_FROM_THEIR_DEFINING_ACL, Boolean.TRUE); return rows; diff --git a/source/java/org/alfresco/repo/domain/permissions/ibatis/AclCrudDAOImpl.java b/source/java/org/alfresco/repo/domain/permissions/ibatis/AclCrudDAOImpl.java index 6cf9e59cb4..2c58fba63d 100644 --- a/source/java/org/alfresco/repo/domain/permissions/ibatis/AclCrudDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/permissions/ibatis/AclCrudDAOImpl.java @@ -33,9 +33,8 @@ import org.alfresco.repo.domain.permissions.AuthorityAliasEntity; import org.alfresco.repo.domain.permissions.AuthorityEntity; import org.alfresco.repo.domain.permissions.PermissionEntity; import org.alfresco.repo.security.permissions.ACEType; -import org.springframework.orm.ibatis.SqlMapClientTemplate; - -import com.ibatis.sqlmap.engine.execution.SqlExecutor; +import org.apache.ibatis.session.RowBounds; +import org.mybatis.spring.SqlSessionTemplate; /** * iBatis-specific implementation of the ACL Crud DAO. @@ -45,7 +44,7 @@ import com.ibatis.sqlmap.engine.execution.SqlExecutor; */ public class AclCrudDAOImpl extends AbstractAclCrudDAOImpl { - private static final String INSERT_ACL = "alfresco.permissions.insert_Acl"; + private static final String INSERT_ACL = "alfresco.permissions.insert.insert_Acl"; private static final String SELECT_ACL_BY_ID = "alfresco.permissions.select_AclById"; private static final String SELECT_ACLS_THAT_INHERIT_FROM_ACL = "alfresco.permissions.select_AclsThatInheritFromAcl"; private static final String SELECT_LATEST_ACL_BY_GUID = "alfresco.permissions.select_LatestAclByGuid"; @@ -54,57 +53,57 @@ public class AclCrudDAOImpl extends AbstractAclCrudDAOImpl private static final String UPDATE_ACL = "alfresco.permissions.update_Acl"; private static final String DELETE_ACL = "alfresco.permissions.delete_Acl"; - private static final String INSERT_ACL_MEMBER = "alfresco.permissions.insert_AclMember"; + private static final String INSERT_ACL_MEMBER = "alfresco.permissions.insert.insert_AclMember"; private static final String SELECT_ACL_MEMBERS_BY_ACL = "alfresco.permissions.select_AclMembersByAclId"; private static final String SELECT_ACL_MEMBERS_BY_AUTHORITY = "alfresco.permissions.select_AclMembersByAuthorityName"; private static final String UPDATE_ACL_MEMBER = "alfresco.permissions.update_AclMember"; private static final String DELETE_ACL_MEMBERS_LIST = "alfresco.permissions.delete_AclMembersList"; private static final String DELETE_ACL_MEMBERS_BY_ACL = "alfresco.permissions.delete_AclMembersByAclId"; - private static final String INSERT_ACL_CHANGESET = "alfresco.permissions.insert_AclChangeSet"; + private static final String INSERT_ACL_CHANGESET = "alfresco.permissions.insert.insert_AclChangeSet"; private static final String SELECT_ACL_CHANGESET_BY_ID = "alfresco.permissions.select_AclChangeSetById"; private static final String DELETE_ACL_CHANGESET = "alfresco.permissions.delete_AclChangeSet"; - private static final String INSERT_ACE = "alfresco.permissions.insert_Ace"; + private static final String INSERT_ACE = "alfresco.permissions.insert.insert_Ace"; private static final String SELECT_ACE_BY_ID = "alfresco.permissions.select_AceById"; private static final String SELECT_ACES_BY_AUTHORITY = "alfresco.permissions.select_AcesByAuthorityId"; private static final String SELECT_ACES_AND_AUTHORIES_BY_ACL = "alfresco.permissions.select_AcesAndAuthoritiesByAclId"; private static final String SELECT_ACE_WITH_NO_CONTEXT = "alfresco.permissions.select_AceWithNoContext"; private static final String DELETE_ACES_LIST = "alfresco.permissions.delete_AcesList"; - private static final String INSERT_ACE_CONTEXT = "alfresco.permissions.insert_AceContext"; + private static final String INSERT_ACE_CONTEXT = "alfresco.permissions.insert.insert_AceContext"; private static final String SELECT_ACE_CONTEXT_BY_ID = "alfresco.permissions.select_AceContextById"; private static final String DELETE_ACE_CONTEXT = "alfresco.permissions.delete_AceContext"; - private static final String INSERT_PERMISSION = "alfresco.permissions.insert_Permission"; + private static final String INSERT_PERMISSION = "alfresco.permissions.insert.insert_Permission"; private static final String SELECT_PERMISSION_BY_ID = "alfresco.permissions.select_PermissionById"; private static final String SELECT_PERMISSION_BY_TYPE_AND_NAME = "alfresco.permissions.select_PermissionByTypeAndName"; private static final String UPDATE_PERMISSION = "alfresco.permissions.update_Permission"; private static final String DELETE_PERMISSION = "alfresco.permissions.delete_Permission"; - private static final String INSERT_AUTHORITY = "alfresco.permissions.insert_Authority"; + private static final String INSERT_AUTHORITY = "alfresco.permissions.insert.insert_Authority"; private static final String SELECT_AUTHORITY_BY_ID = "alfresco.permissions.select_AuthorityById"; private static final String SELECT_AUTHORITY_BY_NAME = "alfresco.permissions.select_AuthorityByName"; private static final String UPDATE_AUTHORITY = "alfresco.permissions.update_Authority"; private static final String DELETE_AUTHORITY = "alfresco.permissions.delete_Authority"; - private static final String INSERT_AUTHORITY_ALIAS = "alfresco.permissions.insert_AuthorityAlias"; + private static final String INSERT_AUTHORITY_ALIAS = "alfresco.permissions.insert.insert_AuthorityAlias"; private static final String DELETE_AUTHORITY_ALIAS = "alfresco.permissions.delete_AuthorityAlias"; - private SqlMapClientTemplate template; + private SqlSessionTemplate template; - public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) + public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) { - this.template = sqlMapClientTemplate; + this.template = sqlSessionTemplate; } + @Override protected AclEntity createAclEntity(AclEntity entity) { entity.setVersion(0L); - Long id = (Long)template.insert(INSERT_ACL, entity); - entity.setId(id); + template.insert(INSERT_ACL, entity); return entity; } @@ -114,7 +113,7 @@ public class AclCrudDAOImpl extends AbstractAclCrudDAOImpl Map params = new HashMap(1); params.put("id", aclEntityId); - return (AclEntity)template.queryForObject(SELECT_ACL_BY_ID, params); + return (AclEntity)template.selectOne(SELECT_ACL_BY_ID, params); } @SuppressWarnings("unchecked") @@ -125,7 +124,7 @@ public class AclCrudDAOImpl extends AbstractAclCrudDAOImpl params.put("id", aclEntityId); params.put("bool", true); - return (List)template.queryForList(SELECT_ACLS_THAT_INHERIT_FROM_ACL, params); + return (List)template.selectList(SELECT_ACLS_THAT_INHERIT_FROM_ACL, params); } @Override @@ -135,7 +134,7 @@ public class AclCrudDAOImpl extends AbstractAclCrudDAOImpl params.put("name", aclGuid); params.put("bool", true); - return (Long)template.queryForObject(SELECT_LATEST_ACL_BY_GUID, params); + return (Long)template.selectOne(SELECT_LATEST_ACL_BY_GUID, params); } @SuppressWarnings("unchecked") @@ -144,13 +143,13 @@ public class AclCrudDAOImpl extends AbstractAclCrudDAOImpl { if (maxResults < 0) { - maxResults = SqlExecutor.NO_MAXIMUM_RESULTS; + maxResults = RowBounds.NO_ROW_LIMIT; } Map params = new HashMap(1); params.put("id", aclEntityId); - return (List)template.queryForList(SELECT_ADM_NODES_BY_ACL, params, 0 , maxResults); + return (List)template.selectList(SELECT_ADM_NODES_BY_ACL, params, new RowBounds(0 , maxResults)); } @SuppressWarnings("unchecked") @@ -159,13 +158,13 @@ public class AclCrudDAOImpl extends AbstractAclCrudDAOImpl { if (maxResults < 0) { - maxResults = SqlExecutor.NO_MAXIMUM_RESULTS; + maxResults = RowBounds.NO_ROW_LIMIT; } Map params = new HashMap(1); params.put("id", aclEntityId); - return (List)template.queryForList(SELECT_AVM_NODES_BY_ACL, params, 0 , maxResults); + return (List)template.selectList(SELECT_AVM_NODES_BY_ACL, params, new RowBounds(0 , maxResults)); } @Override @@ -189,8 +188,7 @@ public class AclCrudDAOImpl extends AbstractAclCrudDAOImpl protected AclMemberEntity createAclMemberEntity(AclMemberEntity entity) { entity.setVersion(0L); - Long id = (Long)template.insert(INSERT_ACL_MEMBER, entity); - entity.setId(id); + template.insert(INSERT_ACL_MEMBER, entity); return entity; } @@ -201,7 +199,7 @@ public class AclCrudDAOImpl extends AbstractAclCrudDAOImpl Map params = new HashMap(1); params.put("id", aclEntityId); - return (List) template.queryForList(SELECT_ACL_MEMBERS_BY_ACL, params); + return (List) template.selectList(SELECT_ACL_MEMBERS_BY_ACL, params); } @SuppressWarnings("unchecked") @@ -211,7 +209,7 @@ public class AclCrudDAOImpl extends AbstractAclCrudDAOImpl Map params = new HashMap(1); params.put("name", authorityName); - return (List) template.queryForList(SELECT_ACL_MEMBERS_BY_AUTHORITY, params); + return (List) template.selectList(SELECT_ACL_MEMBERS_BY_AUTHORITY, params); } @Override @@ -242,7 +240,9 @@ public class AclCrudDAOImpl extends AbstractAclCrudDAOImpl { AclChangeSetEntity entity = new AclChangeSetEntity(); entity.setVersion(0L); - return (Long)template.insert(INSERT_ACL_CHANGESET, entity); + template.insert(INSERT_ACL_CHANGESET, entity); + Long id = entity.getId(); + return (id != null ? id : -1); } @Override @@ -251,7 +251,7 @@ public class AclCrudDAOImpl extends AbstractAclCrudDAOImpl Map params = new HashMap(1); params.put("id", aclChangeSetEntityId); - return (AclChangeSetEntity)template.queryForObject(SELECT_ACL_CHANGESET_BY_ID, params); + return (AclChangeSetEntity)template.selectOne(SELECT_ACL_CHANGESET_BY_ID, params); } @Override @@ -267,7 +267,9 @@ public class AclCrudDAOImpl extends AbstractAclCrudDAOImpl protected long createAceEntity(AceEntity entity) { entity.setVersion(0L); - return (Long)template.insert(INSERT_ACE, entity); + template.insert(INSERT_ACE, entity); + Long id = entity.getId(); + return (id != null ? id : -1); } @Override @@ -276,7 +278,7 @@ public class AclCrudDAOImpl extends AbstractAclCrudDAOImpl Map params = new HashMap(1); params.put("id", aceEntityId); - return (AceEntity)template.queryForObject(SELECT_ACE_BY_ID, params); + return (AceEntity)template.selectOne(SELECT_ACE_BY_ID, params); } @Override @@ -288,7 +290,7 @@ public class AclCrudDAOImpl extends AbstractAclCrudDAOImpl params.put("bool", allowed); params.put("int", type.getId()); - return (AceEntity)template.queryForObject(SELECT_ACE_WITH_NO_CONTEXT, params); + return (AceEntity)template.selectOne(SELECT_ACE_WITH_NO_CONTEXT, params); } @SuppressWarnings("unchecked") @@ -298,7 +300,7 @@ public class AclCrudDAOImpl extends AbstractAclCrudDAOImpl Map params = new HashMap(1); params.put("id", authorityEntityId); - return (List) template.queryForList(SELECT_ACES_BY_AUTHORITY, params); + return (List) template.selectList(SELECT_ACES_BY_AUTHORITY, params); } @SuppressWarnings("unchecked") @@ -308,7 +310,7 @@ public class AclCrudDAOImpl extends AbstractAclCrudDAOImpl Map params = new HashMap(1); params.put("id", aclEntityId); - return (List>) template.queryForList(SELECT_ACES_AND_AUTHORIES_BY_ACL, params); + return (List>) template.selectList(SELECT_ACES_AND_AUTHORIES_BY_ACL, params); } @Override @@ -321,7 +323,9 @@ public class AclCrudDAOImpl extends AbstractAclCrudDAOImpl protected long createAceContextEntity(AceContextEntity entity) { entity.setVersion(0L); - return (Long)template.insert(INSERT_ACE_CONTEXT, entity); + template.insert(INSERT_ACE_CONTEXT, entity); + Long id = entity.getId(); + return (id != null ? id : -1); } @Override @@ -330,7 +334,7 @@ public class AclCrudDAOImpl extends AbstractAclCrudDAOImpl Map params = new HashMap(1); params.put("id", aceContextEntityId); - return (AceContextEntity)template.queryForObject(SELECT_ACE_CONTEXT_BY_ID, params); + return (AceContextEntity)template.selectOne(SELECT_ACE_CONTEXT_BY_ID, params); } @Override @@ -346,8 +350,7 @@ public class AclCrudDAOImpl extends AbstractAclCrudDAOImpl protected PermissionEntity createPermissionEntity(PermissionEntity entity) { entity.setVersion(0L); - Long id = (Long)template.insert(INSERT_PERMISSION, entity); - entity.setId(id); + template.insert(INSERT_PERMISSION, entity); return entity; } @@ -357,7 +360,7 @@ public class AclCrudDAOImpl extends AbstractAclCrudDAOImpl Map params = new HashMap(1); params.put("id", permissionEntityId); - return (PermissionEntity)template.queryForObject(SELECT_PERMISSION_BY_ID, params); + return (PermissionEntity)template.selectOne(SELECT_PERMISSION_BY_ID, params); } @Override @@ -367,7 +370,7 @@ public class AclCrudDAOImpl extends AbstractAclCrudDAOImpl params.put("id", qnameId); params.put("name", name); - return (PermissionEntity)template.queryForObject(SELECT_PERMISSION_BY_TYPE_AND_NAME, params); + return (PermissionEntity)template.selectOne(SELECT_PERMISSION_BY_TYPE_AND_NAME, params); } @Override @@ -391,8 +394,7 @@ public class AclCrudDAOImpl extends AbstractAclCrudDAOImpl protected AuthorityEntity createAuthorityEntity(AuthorityEntity entity) { entity.setVersion(0L); - Long id = (Long)template.insert(INSERT_AUTHORITY, entity); - entity.setId(id); + template.insert(INSERT_AUTHORITY, entity); return entity; } @@ -402,7 +404,7 @@ public class AclCrudDAOImpl extends AbstractAclCrudDAOImpl Map params = new HashMap(1); params.put("id", authorityEntityId); - return (AuthorityEntity)template.queryForObject(SELECT_AUTHORITY_BY_ID, params); + return (AuthorityEntity)template.selectOne(SELECT_AUTHORITY_BY_ID, params); } @SuppressWarnings("unchecked") @@ -415,7 +417,7 @@ public class AclCrudDAOImpl extends AbstractAclCrudDAOImpl // note: allow for list (non-unique name) in case of upgrade of old schemas AuthorityEntity result = null; - List authorities = (List)template.queryForList(SELECT_AUTHORITY_BY_NAME, params); + List authorities = (List)template.selectList(SELECT_AUTHORITY_BY_NAME, params); for (AuthorityEntity found : authorities) { if (found.getAuthority().equals(authorityName)) @@ -448,7 +450,9 @@ public class AclCrudDAOImpl extends AbstractAclCrudDAOImpl protected long createAuthorityAliasEntity(AuthorityAliasEntity entity) { entity.setVersion(0L); - return (Long)template.insert(INSERT_AUTHORITY_ALIAS, entity); + template.insert(INSERT_AUTHORITY_ALIAS, entity); + Long id = entity.getId(); + return (id != null ? id : -1); } @Override diff --git a/source/java/org/alfresco/repo/domain/propval/ibatis/PropertyValueDAOImpl.java b/source/java/org/alfresco/repo/domain/propval/ibatis/PropertyValueDAOImpl.java index 6503ca98ef..d37ab556f9 100644 --- a/source/java/org/alfresco/repo/domain/propval/ibatis/PropertyValueDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/propval/ibatis/PropertyValueDAOImpl.java @@ -22,7 +22,7 @@ import java.io.Serializable; import java.util.Date; import java.util.List; -import org.alfresco.ibatis.RollupRowHandler; +import org.alfresco.ibatis.RollupResultHandler; import org.alfresco.repo.domain.propval.AbstractPropertyValueDAOImpl; import org.alfresco.repo.domain.propval.PropertyClassEntity; import org.alfresco.repo.domain.propval.PropertyDateValueEntity; @@ -39,9 +39,11 @@ import org.alfresco.repo.domain.propval.PropertyUniqueContextEntity; import org.alfresco.repo.domain.propval.PropertyValueEntity; import org.alfresco.repo.domain.propval.PropertyValueEntity.PersistedType; import org.alfresco.util.Pair; -import org.springframework.orm.ibatis.SqlMapClientTemplate; - -import com.ibatis.sqlmap.client.event.RowHandler; +import org.apache.ibatis.session.ResultContext; +import org.apache.ibatis.session.ResultHandler; +import org.apache.ibatis.session.RowBounds; +import org.mybatis.spring.SqlSessionTemplate; +import org.springframework.dao.ConcurrencyFailureException; /** * iBatis-specific implementation of the PropertyValue DAO. @@ -53,53 +55,55 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl { private static final String SELECT_PROPERTY_CLASS_BY_ID = "alfresco.propval.select_PropertyClassByID"; private static final String SELECT_PROPERTY_CLASS_BY_NAME = "alfresco.propval.select_PropertyClassByName"; - private static final String INSERT_PROPERTY_CLASS = "alfresco.propval.insert_PropertyClass"; + private static final String INSERT_PROPERTY_CLASS = "alfresco.propval.insert.insert_PropertyClass"; private static final String SELECT_PROPERTY_DATE_VALUE_BY_ID = "alfresco.propval.select_PropertyDateValueByID"; private static final String SELECT_PROPERTY_DATE_VALUE_BY_VALUE = "alfresco.propval.select_PropertyDateValueByValue"; - private static final String INSERT_PROPERTY_DATE_VALUE = "alfresco.propval.insert_PropertyDateValue"; + private static final String INSERT_PROPERTY_DATE_VALUE = "alfresco.propval.insert.insert_PropertyDateValue"; private static final String SELECT_PROPERTY_STRING_VALUE_BY_ID = "alfresco.propval.select_PropertyStringValueByID"; private static final String SELECT_PROPERTY_STRING_VALUE_BY_VALUE = "alfresco.propval.select_PropertyStringValueByValue"; - private static final String INSERT_PROPERTY_STRING_VALUE = "alfresco.propval.insert_PropertyStringValue"; + private static final String INSERT_PROPERTY_STRING_VALUE = "alfresco.propval.insert.insert_PropertyStringValue"; private static final String SELECT_PROPERTY_DOUBLE_VALUE_BY_ID = "alfresco.propval.select_PropertyDoubleValueByID"; private static final String SELECT_PROPERTY_DOUBLE_VALUE_BY_VALUE = "alfresco.propval.select_PropertyDoubleValueByValue"; - private static final String INSERT_PROPERTY_DOUBLE_VALUE = "alfresco.propval.insert_PropertyDoubleValue"; + private static final String INSERT_PROPERTY_DOUBLE_VALUE = "alfresco.propval.insert.insert_PropertyDoubleValue"; private static final String SELECT_PROPERTY_SERIALIZABLE_VALUE_BY_ID = "alfresco.propval.select_PropertySerializableValueByID"; - private static final String INSERT_PROPERTY_SERIALIZABLE_VALUE = "alfresco.propval.insert_PropertySerializableValue"; + private static final String INSERT_PROPERTY_SERIALIZABLE_VALUE = "alfresco.propval.insert.insert_PropertySerializableValue"; private static final String SELECT_PROPERTY_VALUE_BY_ID = "alfresco.propval.select_PropertyValueById"; private static final String SELECT_PROPERTY_VALUE_BY_LOCAL_VALUE = "alfresco.propval.select_PropertyValueByLocalValue"; private static final String SELECT_PROPERTY_VALUE_BY_DOUBLE_VALUE = "alfresco.propval.select_PropertyValueByDoubleValue"; private static final String SELECT_PROPERTY_VALUE_BY_STRING_VALUE = "alfresco.propval.select_PropertyValueByStringValue"; - private static final String INSERT_PROPERTY_VALUE = "alfresco.propval.insert_PropertyValue"; + private static final String INSERT_PROPERTY_VALUE = "alfresco.propval.insert.insert_PropertyValue"; private static final String SELECT_PROPERTY_BY_ID = "alfresco.propval.select_PropertyById"; private static final String SELECT_PROPERTIES_BY_IDS = "alfresco.propval.select_PropertiesByIds"; private static final String SELECT_PROPERTY_ROOT_BY_ID = "alfresco.propval.select_PropertyRootById"; - private static final String INSERT_PROPERTY_ROOT = "alfresco.propval.insert_PropertyRoot"; + private static final String INSERT_PROPERTY_ROOT = "alfresco.propval.insert.insert_PropertyRoot"; private static final String UPDATE_PROPERTY_ROOT = "alfresco.propval.update_PropertyRoot"; private static final String DELETE_PROPERTY_ROOT_BY_ID = "alfresco.propval.delete_PropertyRootById"; private static final String SELECT_PROPERTY_UNIQUE_CTX_BY_ID = "alfresco.propval.select_PropertyUniqueContextById"; private static final String SELECT_PROPERTY_UNIQUE_CTX_BY_VALUES = "alfresco.propval.select_PropertyUniqueContextByValues"; - private static final String INSERT_PROPERTY_UNIQUE_CTX = "alfresco.propval.insert_PropertyUniqueContext"; + private static final String INSERT_PROPERTY_UNIQUE_CTX = "alfresco.propval.insert.insert_PropertyUniqueContext"; private static final String UPDATE_PROPERTY_UNIQUE_CTX = "alfresco.propval.update_PropertyUniqueContext"; private static final String DELETE_PROPERTY_UNIQUE_CTX_BY_ID = "alfresco.propval.delete_PropertyUniqueContextById"; private static final String DELETE_PROPERTY_UNIQUE_CTX_BY_VALUES = "alfresco.propval.delete_PropertyUniqueContextByValues"; - private static final String INSERT_PROPERTY_LINK = "alfresco.propval.insert_PropertyLink"; + private static final String INSERT_PROPERTY_LINK = "alfresco.propval.insert.insert_PropertyLink"; private static final String DELETE_PROPERTY_LINKS_BY_ROOT_ID = "alfresco.propval.delete_PropertyLinksByRootId"; - private SqlMapClientTemplate template; - - public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) + + private SqlSessionTemplate template; + + public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) { - this.template = sqlMapClientTemplate; + this.template = sqlSessionTemplate; } - + + //================================ // 'alf_prop_class' accessors //================================ @@ -109,7 +113,7 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl { PropertyClassEntity entity = new PropertyClassEntity(); entity.setId(id); - entity = (PropertyClassEntity) template.queryForObject( + entity = (PropertyClassEntity) template.selectOne( SELECT_PROPERTY_CLASS_BY_ID, entity); // Done @@ -121,7 +125,7 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl { PropertyClassEntity entity = new PropertyClassEntity(); entity.setJavaClass(value); - entity = (PropertyClassEntity) template.queryForObject( + entity = (PropertyClassEntity) template.selectOne( SELECT_PROPERTY_CLASS_BY_NAME, entity); // Done @@ -133,8 +137,7 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl { PropertyClassEntity entity = new PropertyClassEntity(); entity.setJavaClass(value); - Long id = (Long) template.insert(INSERT_PROPERTY_CLASS, entity); - entity.setId(id); + template.insert(INSERT_PROPERTY_CLASS, entity); // Done return entity; } @@ -146,7 +149,7 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl @Override protected PropertyDateValueEntity findDateValueById(Long id) { - PropertyDateValueEntity entity = (PropertyDateValueEntity) template.queryForObject( + PropertyDateValueEntity entity = (PropertyDateValueEntity) template.selectOne( SELECT_PROPERTY_DATE_VALUE_BY_ID, id); // Done @@ -156,7 +159,7 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl @Override protected PropertyDateValueEntity findDateValueByValue(Date value) { - PropertyDateValueEntity result = (PropertyDateValueEntity) template.queryForObject( + PropertyDateValueEntity result = (PropertyDateValueEntity) template.selectOne( SELECT_PROPERTY_DATE_VALUE_BY_VALUE, new Long(value.getTime())); // The ID is the actual time in ms (GMT) @@ -182,7 +185,7 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl { PropertyStringValueEntity entity = new PropertyStringValueEntity(); entity.setId(id); - String value = (String) template.queryForObject( + String value = (String) template.selectOne( SELECT_PROPERTY_STRING_VALUE_BY_ID, entity); // Done @@ -195,10 +198,10 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl { PropertyStringValueEntity entity = new PropertyStringValueEntity(); entity.setValue(value); - List rows = (List) template.queryForList( + List rows = (List) template.selectList( SELECT_PROPERTY_STRING_VALUE_BY_VALUE, entity, - 0, 1); + new RowBounds(0, 1)); // The CRC match prevents incorrect results from coming back. Although there could be // several matches, we are sure that the matches are case-sensitive. if (rows.size() > 0) @@ -216,9 +219,9 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl { PropertyStringValueEntity entity = new PropertyStringValueEntity(); entity.setValue(value); - Long id = (Long) template.insert(INSERT_PROPERTY_STRING_VALUE, entity); + template.insert(INSERT_PROPERTY_STRING_VALUE, entity); // Done - return id; + return entity.getId(); } //================================ @@ -230,7 +233,7 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl { PropertyDoubleValueEntity entity = new PropertyDoubleValueEntity(); entity.setId(id); - entity = (PropertyDoubleValueEntity) template.queryForObject( + entity = (PropertyDoubleValueEntity) template.selectOne( SELECT_PROPERTY_DOUBLE_VALUE_BY_ID, entity); // Done @@ -243,10 +246,10 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl { PropertyDoubleValueEntity entity = new PropertyDoubleValueEntity(); entity.setDoubleValue(value); - List results = (List) template.queryForList( + List results = (List) template.selectList( SELECT_PROPERTY_DOUBLE_VALUE_BY_VALUE, entity, - 0, 1); + new RowBounds(0, 1)); // There could be several matches, so just get one if (results.size() > 0) { @@ -264,8 +267,7 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl { PropertyDoubleValueEntity entity = new PropertyDoubleValueEntity(); entity.setDoubleValue(value); - Long id = (Long) template.insert(INSERT_PROPERTY_DOUBLE_VALUE, entity); - entity.setId(id); + template.insert(INSERT_PROPERTY_DOUBLE_VALUE, entity); // Done return entity; } @@ -279,7 +281,7 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl { PropertySerializableValueEntity entity = new PropertySerializableValueEntity(); entity.setId(id); - entity = (PropertySerializableValueEntity) template.queryForObject( + entity = (PropertySerializableValueEntity) template.selectOne( SELECT_PROPERTY_SERIALIZABLE_VALUE_BY_ID, entity); // Done @@ -291,8 +293,7 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl { PropertySerializableValueEntity entity = new PropertySerializableValueEntity(); entity.setSerializableValue(value); - Long id = (Long) template.insert(INSERT_PROPERTY_SERIALIZABLE_VALUE, entity); - entity.setId(id); + template.insert(INSERT_PROPERTY_SERIALIZABLE_VALUE, entity); // Done return entity; } @@ -307,7 +308,7 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl { PropertyValueEntity entity = new PropertyValueEntity(); entity.setId(id); - List results = (List) template.queryForList( + List results = (List) template.selectList( SELECT_PROPERTY_VALUE_BY_ID, entity); // At most one of the results represents a real value @@ -388,7 +389,7 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl if (query != null) { // Uniqueness is guaranteed by the tables, so we get one value only - result = (PropertyValueEntity) template.queryForObject(query, queryObject); + result = (PropertyValueEntity) template.selectOne(query, queryObject); } // Done @@ -436,8 +437,7 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl } // Persist the entity - Long id = (Long) template.insert(INSERT_PROPERTY_VALUE, insertEntity); - insertEntity.setId(id); + template.insert(INSERT_PROPERTY_VALUE, insertEntity); // Done return insertEntity; } @@ -452,7 +452,7 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl { PropertyValueEntity entity = new PropertyValueEntity(); entity.setId(id); - List results = (List) template.queryForList( + List results = (List) template.selectList( SELECT_PROPERTY_BY_ID, entity); return results; @@ -462,11 +462,11 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl @Override protected void findPropertiesByIds(List ids, final PropertyFinderCallback callback) { - RowHandler valueRowHandler = new RowHandler() + ResultHandler valueResultHandler = new ResultHandler() { - public void handleRow(Object valueObject) + public void handleResult(ResultContext context) { - PropertyIdQueryResult result = (PropertyIdQueryResult) valueObject; + PropertyIdQueryResult result = (PropertyIdQueryResult) context.getResultObject(); Long id = result.getPropId(); // Make the serializable value List rows = result.getPropValues(); @@ -475,16 +475,16 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl } }; // A row handler to roll up individual rows - RollupRowHandler rollupRowHandler = new RollupRowHandler( + RollupResultHandler rollupResultHandler = new RollupResultHandler( KEY_COLUMNS_FINDBYIDS, "propValues", - valueRowHandler); + valueResultHandler); // Query using the IDs PropertyIdQueryParameter params = new PropertyIdQueryParameter(); params.setRootPropIds(ids); - template.queryWithRowHandler(SELECT_PROPERTIES_BY_IDS, params, rollupRowHandler); + template.select(SELECT_PROPERTIES_BY_IDS, params, rollupResultHandler); // Process any remaining results - rollupRowHandler.processLastResults(); + rollupResultHandler.processLastResults(); // Done } @@ -493,7 +493,8 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl { PropertyRootEntity rootEntity = new PropertyRootEntity(); rootEntity.setVersion((short)0); - return (Long) template.insert(INSERT_PROPERTY_ROOT, rootEntity); + template.insert(INSERT_PROPERTY_ROOT, rootEntity); + return rootEntity.getId(); } @Override @@ -501,14 +502,19 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl { PropertyRootEntity entity = new PropertyRootEntity(); entity.setId(id); - return (PropertyRootEntity) template.queryForObject(SELECT_PROPERTY_ROOT_BY_ID, entity); + return (PropertyRootEntity) template.selectOne(SELECT_PROPERTY_ROOT_BY_ID, entity); } @Override protected PropertyRootEntity updatePropertyRoot(PropertyRootEntity entity) { entity.incrementVersion(); - template.update(UPDATE_PROPERTY_ROOT, entity, 1); + int updated = template.update(UPDATE_PROPERTY_ROOT, entity); + if (updated != 1) + { + // unexpected number of rows affected + throw new ConcurrencyFailureException("Incorrect number of rows affected for updatePropertyRoot: " + entity + ": expected 1, actual " + updated); + } return entity; } @@ -530,8 +536,7 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl entity.setValue2PropId(valueId2); entity.setValue3PropId(valueId3); entity.setPropertyId(propertyId); - Long id = (Long) template.insert(INSERT_PROPERTY_UNIQUE_CTX, entity); - entity.setId(id); + template.insert(INSERT_PROPERTY_UNIQUE_CTX, entity); return entity; } @@ -540,7 +545,7 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl { PropertyUniqueContextEntity entity = new PropertyUniqueContextEntity(); entity.setId(id); - entity = (PropertyUniqueContextEntity) template.queryForObject(SELECT_PROPERTY_UNIQUE_CTX_BY_ID, entity); + entity = (PropertyUniqueContextEntity) template.selectOne(SELECT_PROPERTY_UNIQUE_CTX_BY_ID, entity); return entity; } @@ -551,7 +556,7 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl entity.setValue1PropId(valueId1); entity.setValue2PropId(valueId2); entity.setValue3PropId(valueId3); - entity = (PropertyUniqueContextEntity) template.queryForObject(SELECT_PROPERTY_UNIQUE_CTX_BY_VALUES, entity); + entity = (PropertyUniqueContextEntity) template.selectOne(SELECT_PROPERTY_UNIQUE_CTX_BY_VALUES, entity); return entity; } @@ -577,11 +582,11 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl } } - RowHandler valueRowHandler = new RowHandler() + ResultHandler valueResultHandler = new ResultHandler() { - public void handleRow(Object valueObject) + public void handleResult(ResultContext context) { - PropertyUniqueContextEntity result = (PropertyUniqueContextEntity) valueObject; + PropertyUniqueContextEntity result = (PropertyUniqueContextEntity) context.getResultObject(); Long id = result.getId(); Long propId = result.getPropertyId(); @@ -594,7 +599,7 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl } }; - template.queryWithRowHandler(SELECT_PROPERTY_UNIQUE_CTX_BY_VALUES, entity, valueRowHandler); + template.select(SELECT_PROPERTY_UNIQUE_CTX_BY_VALUES, entity, valueResultHandler); // Done } @@ -602,7 +607,12 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl protected PropertyUniqueContextEntity updatePropertyUniqueContext(PropertyUniqueContextEntity entity) { entity.incrementVersion(); - template.update(UPDATE_PROPERTY_UNIQUE_CTX, entity, 1); + int updated = template.update(UPDATE_PROPERTY_UNIQUE_CTX, entity); + if (updated != 1) + { + // unexpected number of rows affected + throw new ConcurrencyFailureException("Incorrect number of rows affected for updatePropertyUniqueContext: " + entity + ": expected 1, actual " + updated); + } return entity; } diff --git a/source/java/org/alfresco/repo/domain/qname/ibatis/QNameDAOImpl.java b/source/java/org/alfresco/repo/domain/qname/ibatis/QNameDAOImpl.java index 8c05ff579b..7242a3899d 100644 --- a/source/java/org/alfresco/repo/domain/qname/ibatis/QNameDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/qname/ibatis/QNameDAOImpl.java @@ -21,7 +21,7 @@ package org.alfresco.repo.domain.qname.ibatis; import org.alfresco.repo.domain.qname.AbstractQNameDAOImpl; import org.alfresco.repo.domain.qname.NamespaceEntity; import org.alfresco.repo.domain.qname.QNameEntity; -import org.springframework.orm.ibatis.SqlMapClientTemplate; +import org.mybatis.spring.SqlSessionTemplate; /** * iBatis-specific extension of the QName and Namespace abstract DAO @@ -33,26 +33,27 @@ public class QNameDAOImpl extends AbstractQNameDAOImpl { private static final String SELECT_NS_BY_ID = "alfresco.qname.select_NamespaceById"; private static final String SELECT_NS_BY_URI = "alfresco.qname.select_NamespaceByUri"; - private static final String INSERT_NS = "alfresco.qname.insert_Namespace"; + private static final String INSERT_NS = "alfresco.qname.insert.insert_Namespace"; private static final String UPDATE_NS = "alfresco.qname.update_Namespace"; private static final String SELECT_QNAME_BY_ID = "alfresco.qname.select_QNameById"; private static final String SELECT_QNAME_BY_NS_AND_LOCALNAME = "alfresco.qname.select_QNameByNsAndLocalName"; - private static final String INSERT_QNAME = "alfresco.qname.insert_QName"; + private static final String INSERT_QNAME = "alfresco.qname.insert.insert_QName"; private static final String UPDATE_QNAME = "alfresco.qname.update_QName"; - - private SqlMapClientTemplate template; - - public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) + + + private SqlSessionTemplate template; + + public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) { - this.template = sqlMapClientTemplate; + this.template = sqlSessionTemplate; } - + @Override protected NamespaceEntity findNamespaceEntityById(Long id) { NamespaceEntity entity = new NamespaceEntity(); entity.setId(id); - entity = (NamespaceEntity) template.queryForObject(SELECT_NS_BY_ID, entity); + entity = (NamespaceEntity) template.selectOne(SELECT_NS_BY_ID, entity); return entity; } @@ -61,7 +62,7 @@ public class QNameDAOImpl extends AbstractQNameDAOImpl { NamespaceEntity entity = new NamespaceEntity(); entity.setUriSafe(uri); - entity = (NamespaceEntity) template.queryForObject(SELECT_NS_BY_URI, entity); + entity = (NamespaceEntity) template.selectOne(SELECT_NS_BY_URI, entity); return entity; } @@ -88,7 +89,7 @@ public class QNameDAOImpl extends AbstractQNameDAOImpl { QNameEntity entity = new QNameEntity(); entity.setId(id); - entity = (QNameEntity) template.queryForObject(SELECT_QNAME_BY_ID, entity); + entity = (QNameEntity) template.selectOne(SELECT_QNAME_BY_ID, entity); return entity; } @@ -98,7 +99,7 @@ public class QNameDAOImpl extends AbstractQNameDAOImpl QNameEntity entity = new QNameEntity(); entity.setNamespaceId(nsId); entity.setLocalNameSafe(localName); - entity = (QNameEntity) template.queryForObject(SELECT_QNAME_BY_NS_AND_LOCALNAME, entity); + entity = (QNameEntity) template.selectOne(SELECT_QNAME_BY_NS_AND_LOCALNAME, entity); return entity; } diff --git a/source/java/org/alfresco/repo/domain/query/ibatis/CannedQueryDAOImpl.java b/source/java/org/alfresco/repo/domain/query/ibatis/CannedQueryDAOImpl.java index 6edfbb4239..0a93450cae 100644 --- a/source/java/org/alfresco/repo/domain/query/ibatis/CannedQueryDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/query/ibatis/CannedQueryDAOImpl.java @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2005-2010 Alfresco Software Limited. * * This file is part of Alfresco @@ -14,84 +14,82 @@ * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.domain.query.ibatis; - -import java.sql.Savepoint; - -import org.alfresco.repo.domain.query.AbstractCannedQueryDAOImpl; -import org.alfresco.repo.domain.query.QueryException; -import org.alfresco.util.PropertyCheck; -import org.springframework.orm.ibatis.SqlMapClientTemplate; - -/** - * DAO implementation providing canned query support. - * - * @author Derek Hulley - * @since 3.5 - */ -public class CannedQueryDAOImpl extends AbstractCannedQueryDAOImpl -{ - private SqlMapClientTemplate template; - - public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) - { - this.template = sqlMapClientTemplate; - } - - @Override - public void init() - { - super.init(); - PropertyCheck.mandatory(this, "template", template); - } - - /** - * {@inheritDoc} - *

- * Only one return value is allowed and is checked to prevent null returns. - */ - @Override - public Long executeCountQuery(String sqlNamespace, String queryName, Object parameterObj) - { - String query = new StringBuilder(sqlNamespace.length() + queryName.length() + 1) - .append(sqlNamespace).append(".").append(queryName).toString(); - - try - { - Long result = (Long) template.queryForObject(query, parameterObj); - if (result == null) - { - result = 0L; - } - - // Done - if (logger.isDebugEnabled()) - { - logger.debug( - "Executed query: \n" + - " Query: " + query + "\n" + - " Params: " + parameterObj + "\n" + - " Result: " + result); - } - return result; - } - catch (ClassCastException e) - { - throw new QueryException( - "Count query results must return exactly one Long value: \n" + - " Query: " + query + "\n" + - " Params: " + parameterObj, - e); - } - catch (Throwable e) - { - throw new QueryException( - "Failed to execute query: \n" + - " Query: " + query + "\n" + - " Params: " + parameterObj, - e); - } - } -} + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.domain.query.ibatis; + +import org.alfresco.repo.domain.query.AbstractCannedQueryDAOImpl; +import org.alfresco.repo.domain.query.QueryException; +import org.alfresco.util.PropertyCheck; +import org.mybatis.spring.SqlSessionTemplate; + +/** + * DAO implementation providing canned query support. + * + * @author Derek Hulley + * @since 3.5 + */ +public class CannedQueryDAOImpl extends AbstractCannedQueryDAOImpl +{ + private SqlSessionTemplate template; + + public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) + { + this.template = sqlSessionTemplate; + } + + @Override + public void init() + { + super.init(); + PropertyCheck.mandatory(this, "template", template); + } + + /** + * {@inheritDoc} + *

+ * Only one return value is allowed and is checked to prevent null returns. + */ + @Override + public Long executeCountQuery(String sqlNamespace, String queryName, Object parameterObj) + { + String query = new StringBuilder(sqlNamespace.length() + queryName.length() + 1) + .append(sqlNamespace).append(".").append(queryName).toString(); + + try + { + Long result = (Long) template.selectOne(query, parameterObj); + if (result == null) + { + result = 0L; + } + + // Done + if (logger.isDebugEnabled()) + { + logger.debug( + "Executed query: \n" + + " Query: " + query + "\n" + + " Params: " + parameterObj + "\n" + + " Result: " + result); + } + return result; + } + catch (ClassCastException e) + { + throw new QueryException( + "Count query results must return exactly one Long value: \n" + + " Query: " + query + "\n" + + " Params: " + parameterObj, + e); + } + catch (Throwable e) + { + throw new QueryException( + "Failed to execute query: \n" + + " Query: " + query + "\n" + + " Params: " + parameterObj, + e); + } + } +} diff --git a/source/java/org/alfresco/repo/domain/schema/SchemaBootstrap.java b/source/java/org/alfresco/repo/domain/schema/SchemaBootstrap.java index ab85bc1350..1af4955829 100644 --- a/source/java/org/alfresco/repo/domain/schema/SchemaBootstrap.java +++ b/source/java/org/alfresco/repo/domain/schema/SchemaBootstrap.java @@ -42,7 +42,7 @@ import java.util.Properties; import javax.sql.DataSource; import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.ibatis.SerializableTypeHandlerCallback; +import org.alfresco.ibatis.SerializableTypeHandler; import org.alfresco.repo.admin.patch.Patch; import org.alfresco.repo.admin.patch.impl.SchemaUpgradeScriptPatch; import org.alfresco.repo.content.filestore.FileContentWriter; @@ -1266,7 +1266,7 @@ public class SchemaBootstrap extends AbstractLifecycleBean } int maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH; - int serializableType = SerializableTypeHandlerCallback.getSerializableType(); + int serializableType = SerializableTypeHandler.getSerializableType(); // Adjust the maximum allowable String length according to the dialect if (dialect instanceof AlfrescoSQLServerDialect) { @@ -1312,7 +1312,7 @@ public class SchemaBootstrap extends AbstractLifecycleBean maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH; } SchemaBootstrap.setMaxStringLength(maxStringLength); - SerializableTypeHandlerCallback.setSerializableType(serializableType); + SerializableTypeHandler.setSerializableType(serializableType); // Now override the maximum string length if it was set directly if (maximumStringLength > 0) diff --git a/source/java/org/alfresco/repo/domain/solr/ibatis/SOLRDAOImpl.java b/source/java/org/alfresco/repo/domain/solr/ibatis/SOLRDAOImpl.java index 9b0de872a5..d765560e32 100644 --- a/source/java/org/alfresco/repo/domain/solr/ibatis/SOLRDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/solr/ibatis/SOLRDAOImpl.java @@ -11,7 +11,8 @@ import org.alfresco.repo.domain.solr.NodeParameters; import org.alfresco.repo.domain.solr.SOLRDAO; import org.alfresco.repo.domain.solr.SOLRTransactionParameters; import org.alfresco.repo.domain.solr.Transaction; -import org.springframework.orm.ibatis.SqlMapClientTemplate; +import org.apache.ibatis.session.RowBounds; +import org.mybatis.spring.SqlSessionTemplate; /** * DAO support for SOLR web scripts. @@ -24,18 +25,16 @@ public class SOLRDAOImpl implements SOLRDAO private static final String SELECT_NODES = "alfresco.solr.select_Txn_Nodes"; private QNameDAO qnameDAO; - private SqlMapClientTemplate template; - - public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) + + + private SqlSessionTemplate template; + + public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) { - this.template = sqlMapClientTemplate; - } - - public SqlMapClientTemplate getSqlMapClientTemplate() - { - return this.template; + this.template = sqlSessionTemplate; } + public void setQNameDAO(QNameDAO qnameDAO) { this.qnameDAO = qnameDAO; @@ -63,11 +62,11 @@ public class SOLRDAOImpl implements SOLRDAO if(maxResults != 0 && maxResults != Integer.MAX_VALUE) { - txns = (List)template.queryForList(SELECT_TRANSACTIONS, params, 0, maxResults); + txns = (List)template.selectList(SELECT_TRANSACTIONS, params, new RowBounds(0, maxResults)); } else { - txns = (List)template.queryForList(SELECT_TRANSACTIONS, params); + txns = (List)template.selectList(SELECT_TRANSACTIONS, params); } return txns; @@ -106,11 +105,11 @@ public class SOLRDAOImpl implements SOLRDAO if(maxResults != 0 && maxResults != Integer.MAX_VALUE) { - nodes = (List)template.queryForList(SELECT_NODES, nodeParameters, 0, maxResults); + nodes = (List)template.selectList(SELECT_NODES, nodeParameters, new RowBounds(0, maxResults)); } else { - nodes = (List)template.queryForList(SELECT_NODES, nodeParameters); + nodes = (List)template.selectList(SELECT_NODES, nodeParameters); } for(NodeEntity node : nodes) diff --git a/source/java/org/alfresco/repo/domain/usage/ibatis/UsageDAOImpl.java b/source/java/org/alfresco/repo/domain/usage/ibatis/UsageDAOImpl.java index 9d8d4b9451..19d37a6789 100644 --- a/source/java/org/alfresco/repo/domain/usage/ibatis/UsageDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/usage/ibatis/UsageDAOImpl.java @@ -30,9 +30,9 @@ import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.util.Pair; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.orm.ibatis.SqlMapClientTemplate; - -import com.ibatis.sqlmap.client.event.RowHandler; +import org.apache.ibatis.session.ResultContext; +import org.apache.ibatis.session.ResultHandler; +import org.mybatis.spring.SqlSessionTemplate; /** * iBatis-specific implementation of the Usage DAO. @@ -44,7 +44,7 @@ public class UsageDAOImpl extends AbstractUsageDAOImpl { private static Log logger = LogFactory.getLog(UsageDAOImpl.class); - private static final String INSERT_USAGE_DELTA = "alfresco.usage.insert_UsageDelta"; + private static final String INSERT_USAGE_DELTA = "alfresco.usage.insert.insert_UsageDelta"; private static final String SELECT_USAGE_DELTA_TOTAL_SIZE_BY_NODE = "alfresco.usage.select_GetTotalDeltaSizeByNodeId"; private static final String SELECT_USAGE_DELTA_NODES = "alfresco.usage.select_GetUsageDeltaNodes"; private static final String SELECT_USERS_WITH_USAGE = "alfresco.usage.select_GetUsersWithUsage"; @@ -53,14 +53,16 @@ public class UsageDAOImpl extends AbstractUsageDAOImpl private static final String DELETE_USAGE_DELTAS_BY_NODE = "alfresco.usage.delete_UsageDeltasByNodeId"; - private SqlMapClientTemplate template; - private QNameDAO qnameDAO; + private SqlSessionTemplate template; - public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) + public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) { - this.template = sqlMapClientTemplate; + this.template = sqlSessionTemplate; } + + private QNameDAO qnameDAO; + public void setQnameDAO(QNameDAO qnameDAO) { this.qnameDAO = qnameDAO; @@ -70,8 +72,7 @@ public class UsageDAOImpl extends AbstractUsageDAOImpl protected UsageDeltaEntity insertUsageDeltaEntity(UsageDeltaEntity entity) { entity.setVersion(0L); - Long id = (Long)template.insert(INSERT_USAGE_DELTA, entity); - entity.setId(id); + template.insert(INSERT_USAGE_DELTA, entity); return entity; } @@ -81,14 +82,14 @@ public class UsageDAOImpl extends AbstractUsageDAOImpl Map params = new HashMap(1); params.put("id", nodeEntityId); - return (UsageDeltaEntity) template.queryForObject(SELECT_USAGE_DELTA_TOTAL_SIZE_BY_NODE, params); + return (UsageDeltaEntity) template.selectOne(SELECT_USAGE_DELTA_TOTAL_SIZE_BY_NODE, params); } @SuppressWarnings("unchecked") @Override protected List selectUsageDeltaNodes() { - return (List) template.queryForList(SELECT_USAGE_DELTA_NODES); + return (List) template.selectList(SELECT_USAGE_DELTA_NODES); } @Override @@ -123,13 +124,13 @@ public class UsageDAOImpl extends AbstractUsageDAOImpl params.put("storeProtocol", storeRef.getProtocol()); params.put("storeIdentifier", storeRef.getIdentifier()); - MapRowHandler rowHandler = new MapRowHandler(resultsCallback); + MapResultHandler resultHandler = new MapResultHandler(resultsCallback); - template.queryWithRowHandler(SELECT_USERS_WITHOUT_USAGE, params, rowHandler); + template.select(SELECT_USERS_WITHOUT_USAGE, params, resultHandler); if (logger.isDebugEnabled()) { - logger.debug(" Listed " + rowHandler.total + " users without usage"); + logger.debug(" Listed " + resultHandler.total + " users without usage"); } } @@ -156,13 +157,13 @@ public class UsageDAOImpl extends AbstractUsageDAOImpl params.put("storeProtocol", storeRef.getProtocol()); params.put("storeIdentifier", storeRef.getIdentifier()); - MapRowHandler rowHandler = new MapRowHandler(resultsCallback); + MapResultHandler resultHandler = new MapResultHandler(resultsCallback); - template.queryWithRowHandler(SELECT_USERS_WITH_USAGE, params, rowHandler); + template.select(SELECT_USERS_WITH_USAGE, params, resultHandler); if (logger.isDebugEnabled()) { - logger.debug(" Listed " + rowHandler.total + " users with usage"); + logger.debug(" Listed " + resultHandler.total + " users with usage"); } } @@ -182,7 +183,7 @@ public class UsageDAOImpl extends AbstractUsageDAOImpl Long ownerPropQNameEntityId = ownerPropQNamePair.getFirst(); Long contentPropQNameEntityId = contentPropQNamePair.getFirst(); - MapRowHandler rowHandler = new MapRowHandler(resultsCallback); + MapResultHandler resultHandler = new MapResultHandler(resultsCallback); Map params = new HashMap(5); params.put("contentTypeQNameID", contentTypeQNameEntityId); // cm:content (type) @@ -192,32 +193,32 @@ public class UsageDAOImpl extends AbstractUsageDAOImpl params.put("storeIdentifier", storeRef.getIdentifier()); // Query for the 'new' (FK) style content data properties (stored in 'string_value') - template.queryWithRowHandler(SELECT_CONTENT_SIZES_NEW, params, rowHandler); + template.select(SELECT_CONTENT_SIZES_NEW, params, resultHandler); if (logger.isDebugEnabled()) { - logger.debug(" Listed " + rowHandler.total + " old content sizes"); + logger.debug(" Listed " + resultHandler.total + " old content sizes"); } } /** * Row handler for getting map of strings */ - private static class MapRowHandler implements RowHandler + private static class MapResultHandler implements ResultHandler { private final MapHandler handler; private int total = 0; - private MapRowHandler(MapHandler handler) + private MapResultHandler(MapHandler handler) { this.handler = handler; } @SuppressWarnings("unchecked") - public void handleRow(Object valueObject) + public void handleResult(ResultContext context) { - handler.handle((Map)valueObject); + handler.handle((Map)context.getResultObject()); total++; if (logger.isDebugEnabled() && (total == 0 || (total % 1000 == 0) )) { diff --git a/source/java/org/alfresco/repo/transaction/RetryingTransactionHelper.java b/source/java/org/alfresco/repo/transaction/RetryingTransactionHelper.java index d1e0ef646a..b3d8fb2b02 100644 --- a/source/java/org/alfresco/repo/transaction/RetryingTransactionHelper.java +++ b/source/java/org/alfresco/repo/transaction/RetryingTransactionHelper.java @@ -55,8 +55,6 @@ import org.springframework.dao.DeadlockLoserDataAccessException; import org.springframework.jdbc.JdbcUpdateAffectedIncorrectNumberOfRowsException; import org.springframework.jdbc.UncategorizedSQLException; -import com.ibatis.common.jdbc.exception.NestedSQLException; - /** * A helper that runs a unit of work inside a UserTransaction, * transparently retrying the unit of work if the cause of @@ -99,7 +97,6 @@ public class RetryingTransactionHelper ConstraintViolationException.class, UncategorizedSQLException.class, SQLException.class, - NestedSQLException.class, BatchUpdateException.class, DataIntegrityViolationException.class, StaleStateException.class, @@ -560,7 +557,7 @@ public class RetryingTransactionHelper { return null; } - else if (retryCause instanceof NestedSQLException || retryCause instanceof UncategorizedSQLException) + else if (retryCause instanceof UncategorizedSQLException) { // The exception will have been caused by something else, so check that instead if (retryCause.getCause() != null && retryCause.getCause() != retryCause)