Community
Participate
Working Groups
Build Identifier: eclipselink-2.3.0.v20110604-r9504 Using entity: @Entity @Table(name="EMPLOYEE") public class Employee implements java.io.Serializable { private int id; private String firstName; private String lastName; private float salary; public Employee() { } public Employee(int id, String firstName, String lastName, float salary) { this.id = id; this.firstName = firstName; this.lastName = lastName; this.salary = salary; } // =========================================================== // getters and setters for the state fields @Id @Column(name="ID") public int getId() { return id; } public void setId(int id) { this.id = id; } @Column(name="FIRSTNAME") public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } @Column(name="LASTNAME") public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } @Column(name="SALARY") public float getSalary() { return salary; } public void setSalary(float salary) { this.salary = salary; } ------------------ client code: et.begin(); EntityManager em = getEntityManager(); Query query = em.createQuery( "select e from Employee e where e.id < 10 "); query.setLockMode(LockModeType.PESSIMISTIC_READ); Collection<Employee> c = query.getResultList(); et.commit(); System.out.println("isActive="+getEntityTransaction().isActive()); int expected = 9; int found = 0; for (Employee e : c) { try { em.getLockMode(e); } catch (TransactionRequiredException tre) { found++; } } if (found == expected) { System.out.println("Got expected number of TransactionRequiredExceptions"+expected); } else { System.out.println("Number of TransactionRequiredException Expected:" + c.size() + ", Actual:" + found); } ------------------ output: isActive=false Number of TransactionRequiredException Expected:9, Actual:0 Reproducible: Always
Updating target milestone.
Created attachment 226574 [details] proposed fix
Bugs 366407, 366427, 366464, 382537 fixed in same transaction Reviewed by Guy Pelletier Tests added to JPA 2.1 test suites, QueryTestSuite, EntityManagerTestSuite and EntityManagerFactoryTestSuite Tested with JPA LRG
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink