if (val == null) return null;
Byte[] bytes = (Byte[]) val;
int length = bytes.length;
byte[] result = new byte[length];
for ( int i = 0; i < length ; i++ ) {
if (bytes[i] == null)
throw new HibernateException("Unable to store an Byte[] when one of its element is null");
result[i] = bytes[i].byteValue();
}
return result;