0 Replies Latest reply on Feb 21, 2002 12:58 PM by Alberto

    ClassCastException getting an Object from Database

    Alberto Newbie

      I use Jboss 2.4.3. with Windows 2000 and Jetty3.1.3.
      I have an CMP entity bean with a persistent variable Var which is an Object and the following mapping in jaws:

      <type-mapping>
      MS SQLSERVER

      <java-type>java.lang.Object</java-type>
      <jdbc-type>LONGVARBINARY</jdbc-type>
      <sql-type>varbinary(8000) NULL</sql-type>



      <java-type>java.lang.String</java-type>
      <jdbc-type>LONGVARCHAR</jdbc-type>
      <sql-type>varchar(256) NULL</sql-type>

      etc.......

      The problem is that I store a object from the class String in Var. It maps it to a varbinary. Then I close Jboss and start it again. I retrive the Object contained by Var. And when I try to cast it to a String again as it originally was, it throws a ClassCastException.

      Is there anyway to fix it so that I can save a object of any class as an Object with CMP and then get the original object (to its own class) with a cast or anything?

      Thanks in advance, and excuse me because of my bad english (i'm improving it)