Skip to content

Commit

Permalink
Fixed Class Casts exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelvio committed Feb 12, 2014
1 parent fd022df commit b8730c6
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/java/net/kaleidos/hibernate/usertype/HstoreType.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.sql.SQLException;
import java.sql.Types;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.Map;

import net.kaleidos.hibernate.postgresql.hstore.HstoreDomainType;
Expand Down Expand Up @@ -39,8 +40,20 @@ public Class<?> returnedClass() {
@Override
@SuppressWarnings("rawtypes")
public boolean equals(Object x, Object y) throws HibernateException {
Map m1 = (Map) x;
Map m2 = ((HstoreDomainType)y).getDataStore();
Map m1;
Map m2;
if (x instanceof HstoreDomainType){
m1 = ((HstoreDomainType)x).getDataStore();
} else {
m1 = (Map) x;
}

if (y instanceof HstoreDomainType){
m2 = ((HstoreDomainType)y).getDataStore();
} else {
m2 = (Map) y;
}

return m1.equals(m2);
}

Expand All @@ -53,7 +66,12 @@ public int hashCode(Object x) throws HibernateException {
@SuppressWarnings({ "rawtypes", "unchecked" })
public Object deepCopy(Object value) throws HibernateException {
if (value != null) {
Map m = ((HstoreDomainType)value).getDataStore();
Map m;
if (value instanceof HstoreDomainType)
m = ((HstoreDomainType)value).getDataStore();
else
m = (Map)value;

if (m == null) {
m = new HashMap();
}
Expand Down

0 comments on commit b8730c6

Please sign in to comment.