Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 357670 - Lazy Basic Mapping not properly loaded after create, flush, refresh, commit
Summary: Lazy Basic Mapping not properly loaded after create, flush, refresh, commit
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Tom Ware CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-14 14:33 EDT by Tom Ware CLA
Modified: 2022-06-09 10:08 EDT (History)
1 user (show)

See Also:


Attachments
proposed fix (10.51 KB, patch)
2011-09-14 14:45 EDT, 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 Tom Ware CLA 2011-09-14 14:33:54 EDT
If you have a LAZY Basic mapping and populate it in a new object.  A call to flush and then refresh can corrupt it in the shared cache.  Here is a test case for our DDL Generation Model:

    // Bug 
    public void testLazyBlob(){
        EntityManager em = createEntityManager(DDL_TPC_PU);
        beginTransaction(em);
        LuxuryCar car = new LuxuryCar();
        try {
            java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
            java.io.PrintWriter pw = new java.io.PrintWriter(baos);
            pw.print("TestString1");
            pw.close();
            baos.close();
            car.setPic( baos.toByteArray());
        }
        catch (Exception e) {
            e.printStackTrace();
            fail("we failed!!!");
        }
        em.persist(car);
        em.flush();
        em.refresh(car);
        commitTransaction(em);
        em.clear();
        
        car = em.find(LuxuryCar.class, car.getRegNumber());
        byte[] pic = car.getPic();
        assertTrue("Blob was null after flush, refresh, commit.", pic != null);
    }
Comment 1 Tom Ware CLA 2011-09-14 14:45:21 EDT
Created attachment 203357 [details]
proposed fix
Comment 2 Tom Ware CLA 2011-09-15 10:07:15 EDT
Proposed fix propogates change set to a newly built clone from the source during the merge.

Checked into trunk

Reviewed by Andrei Ilitchev

Added test to DDLGenerationTestSuite

Tested with Core and JPA LRG

2.3, 2.2 and 2.1 check-ins to follow.
Comment 3 Tom Ware CLA 2011-09-15 14:56:24 EDT
Retargetting.  Backport is risky due to amount of supporting API that needs to be backported to get the session need to deal with the fetch group.

Changes checked into 2.3.1
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:08:40 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink