Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 47 additions & 2 deletions src/main/groovy/net/kaleidos/hibernate/usertype/ArrayType.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
Expand Down Expand Up @@ -52,7 +53,51 @@ public Serializable disassemble(Object value) throws HibernateException {

@Override
public boolean equals(Object x, Object y) throws HibernateException {
return x == null ? y == null : x.equals(y);
if (x == y) {
return true;
}

if (x == null || y == null) {
return false;
}

if (x instanceof Object[] && y instanceof Object[]) {
return Arrays.deepEquals((Object[]) x, (Object[]) y);
}

if (x instanceof byte[] && y instanceof byte[]) {
return Arrays.equals((byte[]) x, (byte[]) y);
}

if (x instanceof short[] && y instanceof short[]) {
return Arrays.equals((short[]) x, (short[]) y);
}

if (x instanceof int[] && y instanceof int[]) {
return Arrays.equals((int[]) x, (int[]) y);
}

if (x instanceof long[] && y instanceof long[]) {
return Arrays.equals((long[]) x, (long[]) y);
}

if (x instanceof char[] && y instanceof char[]) {
return Arrays.equals((char[]) x, (char[]) y);
}

if (x instanceof float[] && y instanceof float[]) {
return Arrays.equals((float[]) x, (float[]) y);
}

if (x instanceof double[] && y instanceof double[]) {
return Arrays.equals((double[]) x, (double[]) y);
}

if (x instanceof boolean[] && y instanceof boolean[]) {
return Arrays.equals((boolean[]) x, (boolean[]) y);
}

return x.equals(y);
}

@Override
Expand Down Expand Up @@ -173,4 +218,4 @@ private int enumToId(Object enumValue) throws HibernateException {
ensureBidiMapInitialized();
return bidiMap.getKey(enumValue);
}
}
}