2 Replies Latest reply on Nov 3, 2003 8:24 AM by wunderkind

    m:n collections and ClassCastException in ejbPostCreate

    wunderkind

      Hello dear Jboss community:

      I got a problem concerning mysql and cmr. I am wondering why I get a ClassCastException in ejbPostCreate whil working on a m:n relationship. I am creating an ArrayList
      (widely known to implement java.util.Collection) of Long(s).
      This ArrayList is an parameter in both ejbCreate and ejbPostCreate and of course on site of the m:n relation.
      In ejbPostCreate I call a setter to set the collection and
      use the ArrayList as a paramter. Here is the ejbCode:

      /**
      * @return a collection of related Customers
      * @ejb.interface-method view-type="local"
      * @ejb.relation name="customers-accounts"
      * role-name="customer-has-accounts"
      * target-multiple="yes"
      * target-ejb="account"
      * @jboss.relation fk-constraint="true"
      * related-pk-field="id"
      * fk-column="fk_account"
      *
      **/
      public abstract Collection getAccount();
      public abstract void setAccount(Collection accounts);

      /**
      * @ejb:create-method
      */
      public java.lang.Long ejbCreate(CustomerValueObject customerValueObject) throws CreateException {
      System.out.println("\n\n\n\n\n\nCREATE" );
      this.setCustomerNo(customerValueObject.getCustomerNo());
      return null;
      }


      public void ejbPostCreate(CustomerValueObject customerValueObject) throws CreateException {
      System.out.println("\n\n\n\n\n\nEJBPOSTCREATE" );
      System.out.println("Test:" + customerValueObject.getAccounts());
      this.setAccount(customerValueObject.getAccounts());


      While being in ejbPostCreate (.setAcccount...) I get a ClassCast Exception. Anyone out there that knows why?

      The runs in the same vm - localHome....

      thanx you all,

      sven alias wunderkind