1 Reply Latest reply on Jun 3, 2005 2:22 PM by Franco

    How do I add fields to persisted CMP entity beans?

    Jacob Finn Newbie

      I've deployed a CMP entity bean and created several entities. Now I want to add a field to the bean.

      When I restart JBoss and deploy the new version of the bean, an exception is thrown when JBoss goes to retrieve the currently persisted (older version) beans from the database. How can I get around this? Is there some way to tell JBoss to ignore the new fields when loading those entities for the first time? Is there a way to have JBoss add columns to the database?

      The exception that gets thrown currently is like this:

      javax.ejb.EJBException: Load failed; CausedByException is:
       Column not found: NEWFIELD in statement <snip...>

      Related: one of my bean's fields is of type MyClass, and I also want to add a field to MyClass. This causes a different exception, but maybe the solution is similar. The problem occurs upon deserialization of a MyClass object. Here's the exception:

      javax.ejb.EJBException: Internal error getting results for field member myField; CausedByException is:
      Unable to load to deserialize result: java.io.InvalidClassException: my.package.MyClass; local class incompatible: stream classdesc serialVersionUID = 2378131147583431167, local class serialVersionUID = 663476389263984086

      Is there any way to work around this? More to the point, is there a way to have JBoss do the work? The solutions that occur to me would defeat the point of container-managed persistence.