2 Replies Latest reply on Dec 23, 2005 10:18 AM by Tomasz Zab?ocki

    Batch update problem.

    Tomasz Zab?ocki Newbie

      Here is my irritating issue.

      I'm having two entity beans
      One is Film and another one is Copy.

      there is one to many relationship between them (there can be many copies of one film).

      I have created a web form were i put the film data and the count of copies. Then in the bussiness code I'm creating the film i persist the film bean and then i create "count of copies" times Copy bean and fill each copy data. When I try to persist them (the copies) I get ORA-02291 (Parent foreign key not found) - this is because a batch update takes place. The Film is not in the database. When i persist the film, and afterwards persist the copies I don't get this problem but I want to have the copies created immediately when the film data is specified. How can I make JBoss store the film data before storing the copies? I've tried the EntityManager.flush() but it doesn't work...

      it seems like the flush() is the problem. When i go like that:
      em.persist(film);
      em.flush();
      em.refresh(film);

      then i get:
      javax.ejb.EJBException: null; CausedByException is:
      No row with the given identifier exists: [pl.com.filmservice.par.Film#463]

      I would appreciate any help.