1 Reply Latest reply on Mar 25, 2003 10:31 AM by ben holland

    one to many error cmr

    ben holland Newbie

      Hi,

      I get the following when I start to iterate over a Set of objects returned from my Entity bean.

      javax.ejb.NoSuchObjectLocalException: Entity not found: primaryKey=1
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInte
      rceptor.java:181)

      I have captured the sql calls made by jboss and it looks good:

      SET autocommit=0
      14 Query SELECT customer_id FROM mvdc_customer WHERE customer_id=99
      14 Query SELECT name, pword FROM mvdc_customer WHERE (customer_id=99)
      14 Query SELECT pk_id FROM mvdc_customer_details WHERE (fk_customer_id=99)
      14 Query SELECT email_address, fk_customer_id FROM mvdc_customer_details WHERE (pk_id=235)
      14 Query SELECT pk_account_number FROM mvdc_customer_account WHERE (fk_customer_id=99)
      14 Query SELECT pk_account_number,fk_customer_id FROM mvdc_customer_account WHERE (pk_account_number='1') OR (pk_account_number='123') OR (pk_account_number='5789')
      14 Query rollback

      You can see the container looks for the fk and then does a load for each of the primary keys found but it still bombs out.

      The container loads succesfully the Customer and Customer Details entities from the respective tables.

      Anyone got any thoughts.

      Thanks.

        • 1. Re: one to many error cmr
          ben holland Newbie

          I think this could be a bug you know.

          The following code snippets:

          Add a new account to customer bean

          AccountLocalHome accHome =
          (AccountLocalHome) ctx.lookup("local/Account");

          AccountLocal newAccount =
          accHome.create(newAccountNo);


          Then show a list of accs

          InitialContext ctx = new InitialContext();
          //for the lookup
          CustomerLocalHome home = (CustomerLocalHome) ctx.lookup("local/Customer");

          CustomerLocal cust =
          home.findByPrimaryKey(new CustomerPK(customerID));

          String cus_name = cust.getName();

          System.out.println("cust name: "+cus_name);

          Iterator iterator = cust.getAccounts().iterator();

          while(iterator.hasNext()){
          AccountLocal account =(AccountLocal) iterator.next();

          System.out.println(account.getClass());

          Integer accNo = account.getAccountNumber();

          System.out.println("acc no:"+accNo);

          }//end while

          I have updated my jbosscmp xml so that jboss generates the account table but I still get the problem. IT seems to be intermittent.
          I can add several accounts but then I get then entity not found exception found.