diff --git a/src/main/groovy/net/kaleidos/hibernate/usertype/ArrayType.java b/src/main/groovy/net/kaleidos/hibernate/usertype/ArrayType.java index 7998f5b..0dad360 100644 --- a/src/main/groovy/net/kaleidos/hibernate/usertype/ArrayType.java +++ b/src/main/groovy/net/kaleidos/hibernate/usertype/ArrayType.java @@ -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; @@ -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 @@ -173,4 +218,4 @@ private int enumToId(Object enumValue) throws HibernateException { ensureBidiMapInitialized(); return bidiMap.getKey(enumValue); } -} \ No newline at end of file +}