0

In my postgreSQL DB i have a field with the data type int[] trying to mapp this to a Grails domain class column Integer[] the application fails to start:

org.hibernate.type.SerializationException: could not deserialize

Is there any other way to achieve this?

I also tried this: //insurance column: 'rs_insurance', sqlType: "integer[]"

Jacob
  • 3,580
  • 22
  • 82
  • 146

1 Answers1

0

byte[] type is working out-of-box and is mapped to a respective BLOB-type.

If it's not fine with you, you can serialize your array upon saving and deserialize it upon loading:

void setValue( v ) {
  ByteArrayOutputStream baos = new ByteArrayOutputStream()
  baos.withObjectOutputStream{ it.writeObject v }
  blob = baos.toByteArray()
}

def getValue() {
  def out = null
  if( blob ) new ByteArrayInputStream( blob ).withObjectInputStream{ out = it.readObject() }
  out
}
injecteer
  • 20,038
  • 4
  • 45
  • 89