0 Replies Latest reply on Apr 30, 2003 12:26 PM by Davide

    custom data type serialization

    Davide Newbie

      Hi all!
      i'm having a problem writing a custom datatype. I need this because and i need strings longer than 255 chars.
      Also i don't need every string to be longer than 255 and simply changing the lava.lang.String mapping in standardjboss-cmp.xml doesn't make the work. That's why i have to write a custom data type.
      What i don't know is what's the code that i have to implement in my class.
      This is what i have wrote...however in the db row i get the signature of the class but not the value of the inner string.

      import java.io.Serializable;
      import java.io.ObjectStreamException;
      import java.io.IOException;

      public class LongString implements Serializable {

      private String value = "";

      public LongString() {
      value="";
      }
      public LongString(String _initValue) {
      value=_initValue;
      }

      private void writeObject(java.io.ObjectOutputStream out) throws IOException {
      out.write(value.getBytes());
      }

      private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
      value = "";
      int b;
      while ( (b = in.read()) != -1 ) {
      value = value + (char) b;
      }
      }

      public Object writeReplace() throws ObjectStreamException {
      return value;
      }
      public Object readResolve() throws ObjectStreamException {
      return value;
      }


      public String getValue() {
      return value;
      }
      public void setValue(String value) {
      this.value = value;
      }
      }

      Please give me some advice!!!

      Thanks in advance,
      Davide