HHH-10413 : fixes required to backport

(cherry picked from commit 995e76e5fb)
This commit is contained in:
Gail Badner 2016-06-28 23:06:53 -07:00
parent 62c8bb914b
commit 11f2d5d5f7
3 changed files with 9 additions and 8 deletions

View File

@ -24,9 +24,11 @@ public final class RowVersionComparator implements Comparator<byte[]> {
for ( int i = 0 ; i < lengthToCheck ; i++ ) {
// must do an unsigned int comparison
// Byte#toUnsignedInt is available starting in jdk8,
// so directly convert to unsigned int before comparing
final int comparison = ComparableComparator.INSTANCE.compare(
Byte.toUnsignedInt( o1[i] ),
Byte.toUnsignedInt( o2[i] )
( (int) o1[i] ) & 0xff,
( (int) o2[i] ) & 0xff
);
if ( comparison != 0 ) {
return comparison;

View File

@ -8,9 +8,7 @@ package org.hibernate.type;
import java.util.Comparator;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.internal.util.compare.RowVersionComparator;
import org.hibernate.type.descriptor.java.PrimitiveByteArrayTypeDescriptor;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.type.descriptor.java.RowVersionTypeDescriptor;
import org.hibernate.type.descriptor.sql.VarbinaryTypeDescriptor;
@ -42,7 +40,7 @@ public class RowVersionType
}
@Override
public byte[] seed(SharedSessionContractImplementor session) {
public byte[] seed(SessionImplementor session) {
// Note : simply returns null for seed() and next() as the only known
// application of binary types for versioning is for use with the
// TIMESTAMP datatype supported by Sybase and SQL Server, which
@ -51,7 +49,7 @@ public class RowVersionType
}
@Override
public byte[] next(byte[] current, SharedSessionContractImplementor session) {
public byte[] next(byte[] current, SessionImplementor session) {
return current;
}

View File

@ -10,6 +10,7 @@ import javax.persistence.OptimisticLockException;
import org.junit.Test;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.dialect.SybaseASE15Dialect;
@ -69,7 +70,7 @@ public class SybaseTimestampVersioningTest extends BaseCoreFunctionalTestCase {
t2.commit();
fail( "optimistic lock check did not fail" );
}
catch( OptimisticLockException e ) {
catch( HibernateException e ) {
// expected...
try {
t2.rollback();