Bug 421493 - reading outside transaction in extended persistence context results in unmanaged objects
Summary: reading outside transaction in extended persistence context results in unmana...
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 major with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-11 23:24 EST by Michael Keith CLA
Modified: 2022-06-09 10:09 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Keith CLA 2013-11-11 23:24:58 EST
Have a SFSB with an extended persistence context. Running in a method with no tx active (e.g. bean tx mode is set to NOT_SUPPORTED). When I issue a find() call or any query at all from within that non-transactional method, the results come back being unmanaged. This is incorrect and seems to be a regression (this characteristic was not present in earlier versions.) Not sure when it actually broke along the way, though.
Comment 1 Ryan Bennetts CLA 2014-09-05 02:14:28 EDT
I'm seeing the same issue after upgrading from Glassfish 3.1.2.2 (eclipselink 2.3.2) to Glassfish 4.0 (eclipselink 2.5.2).

In my case, I am using bean-managed transactions, but likewise find that a call to EntityManager.find() outside of a transaction does not add the returned entity to the Persistence Context - ie it comes back detached.

I turned the EclipseLink logging way up and discovered that the Unit of Work that is acquired to perform the read (ie find()) operation is released at the end of that operation.

However, if the read operation is performed inside a transaction, then the Unit of Work is not released at the end. Instead, the read entity remains managed, and any subsequent operations performed within a separate transaction reuse the same Unit of Work.

It should not be necessary to perform read operations on an extended persistence context within a transaction just to ensure the entity is registered with the persistence context.
Comment 2 Eclipse Webmaster CLA 2022-06-09 10:02:23 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 3 Eclipse Webmaster CLA 2022-06-09 10:09:03 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink