HHH-5811 : Flush causes update query on field of type Byte[]

This commit is contained in:
Gail Badner 2014-07-09 17:11:09 -07:00
parent ccffe0dea9
commit 4007655045
2 changed files with 17 additions and 1 deletions

View File

@ -27,6 +27,7 @@ import java.io.ByteArrayInputStream;
import java.io.InputStream; import java.io.InputStream;
import java.sql.Blob; import java.sql.Blob;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Arrays;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.jdbc.BinaryStream; import org.hibernate.engine.jdbc.BinaryStream;
@ -45,6 +46,20 @@ public class ByteArrayTypeDescriptor extends AbstractTypeDescriptor<Byte[]> {
public ByteArrayTypeDescriptor() { public ByteArrayTypeDescriptor() {
super( Byte[].class, ArrayMutabilityPlan.INSTANCE ); super( Byte[].class, ArrayMutabilityPlan.INSTANCE );
} }
@Override
public boolean areEqual(Byte[] one, Byte[] another) {
return one == another
|| ( one != null && another != null && Arrays.equals(one, another) );
}
@Override
public int extractHashCode(Byte[] bytes) {
int hashCode = 1;
for ( byte aByte : bytes ) {
hashCode = 31 * hashCode + aByte;
}
return hashCode;
}
@Override @Override
public String toString(Byte[] bytes) { public String toString(Byte[] bytes) {
final StringBuilder buf = new StringBuilder(); final StringBuilder buf = new StringBuilder();

View File

@ -30,6 +30,7 @@ import org.hibernate.Transaction;
import org.hibernate.testing.DialectChecks; import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.FailureExpected; import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.RequiresDialectFeature; import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.TestForIssue;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
@ -146,7 +147,7 @@ public class VersionedLobTest extends AbstractLobTest<VersionedBook, VersionedCo
} }
@Test @Test
@FailureExpected( jiraKey = "HHH-5811") @TestForIssue( jiraKey = "HHH-5811")
public void testVersionUnchangedByteArray() throws Exception { public void testVersionUnchangedByteArray() throws Exception {
Session s; Session s;
Transaction tx; Transaction tx;