3 Replies Latest reply on Dec 30, 2005 3:08 PM by Emmanuel Bernard

    change of subclasse causes error

    Ruud van Kersbergen Newbie

      I have a baseclasse and several subclasses (A,B,C) all of them are saved in one table.

      I need to convert from one to another subclasse. Lets say from A to B.

      I have tried several things:

      1 : create a new instance of B, read A from the database and perform a merge. I got the error :
      A unexpected error : [javax.ejb.EJBException:null; CausedByException is:
      Object with id: null was not of the specified subclass: com.hollandhouse.unispool.entity.beans.LPRDevice (class of the given object did not match class of persistent copy)].

      2 : create a new instance of B, test whether the class of A and B are instanciated from different classes. If so : set B.id equal to A.id and persist. This also goes wrong.

      I dont like the solution : read A, copy every attribute to B, delete A, create B with the id of A. This has consequences for every relationship and several processes.

      Has anybody a suggestion ?

      With kind regards
      Ruud van Kersbergen