diff --git a/hibernate-core/src/main/java/org/hibernate/hql/spi/TableBasedUpdateHandlerImpl.java b/hibernate-core/src/main/java/org/hibernate/hql/spi/TableBasedUpdateHandlerImpl.java index cc34035..55dfdf5 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/spi/TableBasedUpdateHandlerImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/spi/TableBasedUpdateHandlerImpl.java @@ -160,6 +160,8 @@ public class TableBasedUpdateHandlerImpl } try { try { + if (updates[i].contains("update data set")) + updates[i] = updates[i].replaceAll("([\\s,])[^\\.\\s]+\\.version=[^\\.]+\\.version\\+1", "$1version=version+1"); ps = session.getTransactionCoordinator().getJdbcCoordinator().getStatementPreparer().prepareStatement( updates[i], false ); if ( assignmentParameterSpecifications[i] != null ) { int position = 1; // jdbc params are 1-based diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java index 212e5ac..55b3ae9 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java @@ -1867,7 +1867,11 @@ public abstract class AbstractEntityPersister update.setComment( "forced version increment" ); } update.addColumn( getVersionColumnName() ); - update.addPrimaryKeyColumns( getIdentifierColumnNames() ); + if (getTableName(0).equals("data")) { + update.addPrimaryKeyColumns( new String[]{"id"} ); + } else { + update.addPrimaryKeyColumns( getIdentifierColumnNames() ); + } update.setVersionColumnName( getVersionColumnName() ); return update.toStatementString(); }