1 Reply Latest reply on Dec 30, 2005 9:18 PM by epbernard

    EJB3 Batch update issue

    tzablock

      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...

      When i try to do
      em.persist(film);
      em.flush();
      em.refresh(film);

      Then I get an exception 'cause the film seems to be transient...

      I still don't know what to do... when i 've copied Order, Orderline and purchase code from the DVDTRail trailblazer into my application it stopped working...there is the same batch update issue.

      I would appreciate any help.