[ 
https://issues.apache.org/jira/browse/OPENJPA-2061?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Bálint Balázs updated OPENJPA-2061:
-----------------------------------

    Description: 
After EntityManager.flush() is called, no identifier will be generated for 
identifiers annotated with @GeneratedValue:

    EntityTransaction transaction = em.getTransaction();
    transaction.begin();
    Query query = em.createQuery("select m from Master m");
    @SuppressWarnings("unchecked")
    List<Master> l = query.getResultList();

    for (Master m: l) {

      //-- Two additional Detail's are created for each Master.
      m.getDetails().add(createDetail());
      m.getDetails().add(createDetail());

      //-- The following flush() causes the trouble: The second detail is lost 
in the second Master:
      //-- No id will be autogenerated for Detail instance after the flush()
      //-- If you omit this line, the test case works fine.
      em.flush();
    }

    transaction.commit();
    em.close();


  was:
    EntityTransaction transaction = em.getTransaction();
    transaction.begin();
    Query query = em.createQuery("select m from Master m");
    @SuppressWarnings("unchecked")
    List<Master> l = query.getResultList();

    for (Master m: l) {

      //-- Two additional Detail's are created for each Master.
      m.getDetails().add(createDetail());
      m.getDetails().add(createDetail());

      //-- The following flush() causes the trouble: The second detail is lost 
in the second Master:
      //-- No id will be autogenerated for Detail instance after the flush()
      //-- If you omit this line, the test case works fine.
      em.flush();
    }

    transaction.commit();
    em.close();


    
> After EntityManager.flush() is called, no identifier will be generated for 
> identifiers annotated with @GeneratedValue
> ---------------------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-2061
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2061
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 2.1.1
>         Environment: Derby database. The behaviour is the same with Oracle 
> and MySQL, however. It is also independent of the generation strategy
>            Reporter: Bálint Balázs
>         Attachments: Detail.java, Jpacase.java, Master.java
>
>
> After EntityManager.flush() is called, no identifier will be generated for 
> identifiers annotated with @GeneratedValue:
>     EntityTransaction transaction = em.getTransaction();
>     transaction.begin();
>     Query query = em.createQuery("select m from Master m");
>     @SuppressWarnings("unchecked")
>     List<Master> l = query.getResultList();
>     for (Master m: l) {
>       //-- Two additional Detail's are created for each Master.
>       m.getDetails().add(createDetail());
>       m.getDetails().add(createDetail());
>       //-- The following flush() causes the trouble: The second detail is 
> lost in the second Master:
>       //-- No id will be autogenerated for Detail instance after the flush()
>       //-- If you omit this line, the test case works fine.
>       em.flush();
>     }
>     transaction.commit();
>     em.close();

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


Reply via email to