diff --git a/config/alfresco/dbscripts/create/3.2/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoPostCreate-3.2-AuditTables.sql b/config/alfresco/dbscripts/create/3.2/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoPostCreate-3.2-AuditTables.sql
index 1b45a83754..d3cd626977 100644
--- a/config/alfresco/dbscripts/create/3.2/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoPostCreate-3.2-AuditTables.sql
+++ b/config/alfresco/dbscripts/create/3.2/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoPostCreate-3.2-AuditTables.sql
@@ -20,7 +20,7 @@ CREATE TABLE alf_audit_model
CREATE TABLE alf_audit_app
(
id BIGINT NOT NULL AUTO_INCREMENT,
- version TINYINT NOT NULL,
+ version SMALLINT NOT NULL,
app_name_id BIGINT NOT NULL,
audit_model_id BIGINT NOT NULL,
disabled_paths_id BIGINT NOT NULL,
diff --git a/config/alfresco/dbscripts/create/3.2/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoPostCreate-3.2-PropertyValueTables.sql b/config/alfresco/dbscripts/create/3.2/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoPostCreate-3.2-PropertyValueTables.sql
index be0810c338..58d5986998 100644
--- a/config/alfresco/dbscripts/create/3.2/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoPostCreate-3.2-PropertyValueTables.sql
+++ b/config/alfresco/dbscripts/create/3.2/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoPostCreate-3.2-PropertyValueTables.sql
@@ -75,7 +75,7 @@ CREATE TABLE alf_prop_value
CREATE TABLE alf_prop_root
(
id BIGINT NOT NULL AUTO_INCREMENT,
- version TINYINT NOT NULL,
+ version SMALLINT NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB;
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 29cd73e5f9..c8297429b6 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
@@ -132,8 +132,10 @@
audit_model_id = #auditModelId#,
disabled_paths_id = #disabledPathsId#
where
- id = #id# and
- version = (#version# -1)
+ id = #id#
+
+ and version = ((#version#-1))
+
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 9aea4a5bcf..ca505aaa97 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
@@ -363,8 +363,10 @@
set
version = #version#
where
- id = #id# and
- version = (#version# -1)
+ id = #id#
+
+ and version = ((#version#-1))
+
diff --git a/source/java/org/alfresco/repo/domain/propval/PropertyValueDAOTest.java b/source/java/org/alfresco/repo/domain/propval/PropertyValueDAOTest.java
index e122088c43..3a37654f63 100644
--- a/source/java/org/alfresco/repo/domain/propval/PropertyValueDAOTest.java
+++ b/source/java/org/alfresco/repo/domain/propval/PropertyValueDAOTest.java
@@ -26,9 +26,11 @@ package org.alfresco.repo.domain.propval;
import java.io.Serializable;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Random;
@@ -587,6 +589,29 @@ public class PropertyValueDAOTest extends TestCase
assertEquals(list, entityValueCheck);
}
+ public void testProperty_UpdateToVersionRollover() throws Exception
+ {
+ final List list = Collections.emptyList();
+ final Long propId = runPropertyTest((Serializable)list);
+
+ // Do 1000 updates to a property
+ RetryingTransactionCallback updateThousandsCallback = new RetryingTransactionCallback()
+ {
+ public Void execute() throws Throwable
+ {
+ for (int i = 0; i < 1000; i++)
+ {
+ propertyValueDAO.updateProperty(propId, (Serializable)list);
+ }
+ return null;
+ }
+ };
+ for (int i = 0; i < (Short.MAX_VALUE / 1000 + 1); i++)
+ {
+ txnHelper.doInTransaction(updateThousandsCallback, false);
+ }
+ }
+
public void testProperty_Delete() throws Exception
{
final ArrayList list = new ArrayList(20);