// Path: src/main/java/net/canadensys/databaseutils/hibernate/KeyValueType.java
// public class KeyValueType implements UserType {
// 
// 	public Object assemble(Serializable cached, Object owner) throws HibernateException {
// 		return cached;
// 	}
// 
// 	@SuppressWarnings("unchecked")
// 	public Object deepCopy(Object o) throws HibernateException {
// 		if( o == null){
// 			return null;
// 		}
// 		// Not a true deep copy but since the map contains immutable Strings, it's fine.
// 		return new HashMap<String, String>((Map<String, String>) o);
// 	}
// 
// 	public Serializable disassemble(Object o) throws HibernateException {
// 		return (Serializable) o;
// 	}
// 
// 	@SuppressWarnings("deprecation")
// 	public boolean equals(Object o1, Object o2) throws HibernateException {
// 		// deprecated in Java 7
// 		return ObjectUtils.equals(o1, o2);
// 	}
// 
// 	public int hashCode(Object o) throws HibernateException {
// 		return o.hashCode();
// 	}
// 
// 	public boolean isMutable() {
// 		return true;
// 	}
// 
// 	public Object replace(Object original, Object target, Object owner) throws HibernateException {
// 		return original;
// 	}
// 
// 	public Class<?> returnedClass() {
// 		return Map.class;
// 	}
// 
// 	public int[] sqlTypes() {
// 		return new int[] { Types.OTHER };
// 	}
// 
// 	@Override
// 	public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
// 		if(rs.getString(names[0]) == null){
//             return null;
//         }
// 		return rs.getObject(names[0]);
// 	}
// 
// 	@Override
// 	public void nullSafeSet(PreparedStatement ps, Object obj, int index, SessionImplementor session) throws HibernateException, SQLException {
// 		if (obj == null) {
//             ps.setNull(index, Types.OTHER);
//             return;
//         }
// 		// can't use ps.setObject(index, obj, Types.OTHER) for now
// 		// see https://github.com/pgjdbc/pgjdbc/issues/199
// 		ps.setObject(index, obj);
// 	}
// }


import java.util.Map;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import net.canadensys.databaseutils.hibernate.KeyValueType;
import org.hibernate.annotations.NaturalId;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;
package net.canadensys.dataportal.occurrence.model;





/**
 * Model containing data related to a DarwinCore occurrence extension. Data are stored in a key/value map allowing to abstract specific extension columns.
 * @author cgendreau
 *
 */
@Entity
@Table(name = "occurrence_extension")
// Path: src/main/java/net/canadensys/databaseutils/hibernate/KeyValueType.java
// public class KeyValueType implements UserType {
// 
// 	public Object assemble(Serializable cached, Object owner) throws HibernateException {
// 		return cached;
// 	}
// 
// 	@SuppressWarnings("unchecked")
// 	public Object deepCopy(Object o) throws HibernateException {
// 		if( o == null){
// 			return null;
// 		}
// 		// Not a true deep copy but since the map contains immutable Strings, it's fine.
// 		return new HashMap<String, String>((Map<String, String>) o);
// 	}
// 
// 	public Serializable disassemble(Object o) throws HibernateException {
// 		return (Serializable) o;
// 	}
// 
// 	@SuppressWarnings("deprecation")
// 	public boolean equals(Object o1, Object o2) throws HibernateException {
// 		// deprecated in Java 7
// 		return ObjectUtils.equals(o1, o2);
// 	}
// 
// 	public int hashCode(Object o) throws HibernateException {
// 		return o.hashCode();
// 	}
// 
// 	public boolean isMutable() {
// 		return true;
// 	}
// 
// 	public Object replace(Object original, Object target, Object owner) throws HibernateException {
// 		return original;
// 	}
// 
// 	public Class<?> returnedClass() {
// 		return Map.class;
// 	}
// 
// 	public int[] sqlTypes() {
// 		return new int[] { Types.OTHER };
// 	}
// 
// 	@Override
// 	public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
// 		if(rs.getString(names[0]) == null){
//             return null;
//         }
// 		return rs.getObject(names[0]);
// 	}
// 
// 	@Override
// 	public void nullSafeSet(PreparedStatement ps, Object obj, int index, SessionImplementor session) throws HibernateException, SQLException {
// 		if (obj == null) {
//             ps.setNull(index, Types.OTHER);
//             return;
//         }
// 		// can't use ps.setObject(index, obj, Types.OTHER) for now
// 		// see https://github.com/pgjdbc/pgjdbc/issues/199
// 		ps.setObject(index, obj);
// 	}
// }


// Path: src/main/java/net/canadensys/dataportal/occurrence/model/OccurrenceExtensionModel.java
import java.util.Map;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import net.canadensys.databaseutils.hibernate.KeyValueType;
import org.hibernate.annotations.NaturalId;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;

package net.canadensys.dataportal.occurrence.model;





/**
 * Model containing data related to a DarwinCore occurrence extension. Data are stored in a key/value map allowing to abstract specific extension columns.
 * @author cgendreau
 *
 */
@Entity
@Table(name = "occurrence_extension")
@TypeDefs( {@TypeDef( name= "KeyValueType", typeClass = KeyValueType.class)})