glassfish
  1. glassfish
  2. GLASSFISH-19575

[Blocking] Data persisted with a flush under UnsyncPC not joinedTx

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 4.0_b72_EE7MS4
    • Fix Version/s: 4.0_b82_EE7MS7
    • Component/s: entity-persistence
    • Labels:
      None
    • Environment:

      RHL5, JDK1.7.0

      Description

      glassfish-4.0-b72.zip

      The data were persisted into database with em.flush() for unsynchronized persistence
      context not joined to current transaction.

        Activity

        Hide
        sherryshen added a comment - - edited

        The test1 for this scenarios is in a web app with stateless session bean.

        appserver-sqe/pe/ejb/jpa20/war/unsyncpcslsb/web/session/TestEJB.java
        
        @Stateless
        public class TestEJB {
        
        @PersistenceContext(synchronization=SynchronizationType.UNSYNCHRONIZED)
            EntityManager em;
        
            // Should not insert data since it is not joined yet.
            public boolean test1() {
            boolean pass= false;
        
            Employee e1 = new Employee(1, "emp1", 1000);
            Employee e2 = new Employee(2, "emp2", 2000);
            Project p1 = new Project(1, "proj1");
            Collection<Employee> employees = new ArrayList<Employee>();
            employees.add(e1);
            employees.add(e2);
            p1.setEmployees(employees);
            try {
              em.persist(p1);
              em.flush();
            } catch(Throwable e){
                System.out.println("Got Ex");
                pass = true;
            }
               return pass;
          } 
        
        Show
        sherryshen added a comment - - edited The test1 for this scenarios is in a web app with stateless session bean. appserver-sqe/pe/ejb/jpa20/war/unsyncpcslsb/web/session/TestEJB.java @Stateless public class TestEJB { @PersistenceContext(synchronization=SynchronizationType.UNSYNCHRONIZED) EntityManager em; // Should not insert data since it is not joined yet. public boolean test1() { boolean pass= false; Employee e1 = new Employee(1, "emp1", 1000); Employee e2 = new Employee(2, "emp2", 2000); Project p1 = new Project(1, "proj1"); Collection<Employee> employees = new ArrayList<Employee>(); employees.add(e1); employees.add(e2); p1.setEmployees(employees); try { em.persist(p1); em.flush(); } catch(Throwable e){ System.out.println("Got Ex"); pass = true; } return pass; }
        Hide
        sherryshen added a comment -

        Based on the discussion with dev, this looks like a bug in flush.
        As suggested by dev, I filed a bug for EclipseLink
        https://bugs.eclipse.org/bugs/show_bug.cgi?id=398934

        Show
        sherryshen added a comment - Based on the discussion with dev, this looks like a bug in flush. As suggested by dev, I filed a bug for EclipseLink https://bugs.eclipse.org/bugs/show_bug.cgi?id=398934
        Hide
        sherryshen added a comment -

        Need evaluation in order to complete test dev for Glassfish 4.0 JPA2.1.

        Show
        sherryshen added a comment - Need evaluation in order to complete test dev for Glassfish 4.0 JPA2.1.
        Hide
        sherryshen added a comment -

        Verified the fix on
        glassfish-4.0-b82-03_22_2013.zip

        Show
        sherryshen added a comment - Verified the fix on glassfish-4.0-b82-03_22_2013.zip

          People

          • Assignee:
            Mitesh Meswani
            Reporter:
            sherryshen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: