Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 366407 - EntityManager.find(java.lang.Class, Object,LockModeType) does not throw TransactionRequiredException when there is no transaction and a lock mode other than NONE is specified
Summary: EntityManager.find(java.lang.Class, Object,LockModeType) does not throw Trans...
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 blocker (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-12 09:14 EST by Stephen DiMilla CLA
Modified: 2022-06-09 10:31 EDT (History)
3 users (show)

See Also:


Attachments
proposed fix (16.19 KB, patch)
2013-02-05 10:19 EST, Tom Ware CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stephen DiMilla CLA 2011-12-12 09:14:43 EST
Build Identifier: eclipselink-2.3.0.v20110604-r9504

Using the entity:

@Entity
@Table(name="CUSTOMER_TABLE")
public class Customer implements java.io.Serializable
{

    // Instance variables
    private String id;
    private String name;
    public Customer()
    {
    }

    public Customer (String id, String name)
    {
    this.id = id;
    this.name = name;
    }
   @Id
    @Column(name="ID")
    public String getId() {
    return id;
    }
    public void setId(String v) {
    this.id = v;
    }

    @Column(name="NAME")
    public String getName() {
    return name;
    }
    public void setName(String v) {
    this.name = v;
    }
}
----------------------
Using the client code:


        try {
            em.find(Order.class, 1, LockModeType.PESSIMISTIC_READ);
            System.out.println("TransactionRequiredException not thrown");
        } catch (TransactionRequiredException tre) {
            System.out.println("TransactionRequiredException Caught as Expected.");
        } catch (Exception e) {
            System.out.println("Unexpected exception occurred");
            e.printStackTrace();
        }

---------
output:

 TransactionRequiredException not thrown



Reproducible: Always
Comment 1 Stephen DiMilla CLA 2011-12-12 09:16:14 EST
change the following line in the client code to:


            em.find(Customer.class, 1, LockModeType.PESSIMISTIC_READ);
Comment 2 Tom Ware CLA 2012-04-05 11:01:26 EDT
Updating target milestone.
Comment 3 Tom Ware CLA 2013-02-05 10:19:30 EST
Created attachment 226571 [details]
proposed fix
Comment 4 Tom Ware CLA 2013-02-05 11:50:05 EST
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
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:31:58 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink