Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 349974 - WDF faliures due to inheritancePolicy initialization
Summary: WDF faliures due to inheritancePolicy initialization
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: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-21 14:26 EDT by Tom Ware CLA
Modified: 2022-06-09 10:29 EDT (History)
1 user (show)

See Also:


Attachments
Proposed fix (955 bytes, patch)
2011-06-21 14:53 EDT, Tom Ware CLA
no flags Details | Diff
updated patch (2.15 KB, patch)
2011-06-21 15:31 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-06-21 14:26:57 EDT

    
Comment 1 Tom Ware CLA 2011-06-21 14:30:28 EDT
The WDF testArguments test:

    @Test
    public void testSubclassParameter() {
        EntityManager em = getEnvironment().getEntityManager();
        try {
            Query q = em.createQuery("SELECT e FROM Employee e WHERE e.department=?1");
            q.setParameter(1, new KrassDep("foo"));
            q.getResultList();
        } finally {
            closeEntityManager(em);
        }
    }


Causes accidental instantiation of an inheritance policy for Department.

KrassDepartment is an unmapped subclass of Department, and when we are processing the parameter passed into the query, we look in the hierarchy for the descriptor.

We call session.checkHierarchyForDescriptor().  In the RepeatableWriteUnitOfWork implementation this method calls classDescriptor.getInheritancePolicy() without first checking for inheritance.  This causes the inheritancePolicy to be instantiated accidentally.

This issue results in a number of failures later in the tests.  Failures look like this:

java.lang.NullPointerException
at org.eclipse.persistence.internal.sessions.AbstractRecord.get(AbstractRecord.java:276)
at org.eclipse.persistence.descriptors.InheritancePolicy.classFromRow(InheritancePolicy.java:336)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:492)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:463)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:723)
at org.eclipse.persistence.queries.ReadObjectQuery.registerResultInUnitOfWork(ReadObjectQuery.java:766)
at org.eclipse.persistence.queries.ReadObjectQuery.executeObjectLevelReadQuery(ReadObjectQuery.java:451)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1080)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:810)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1040)
at org.eclipse.persistence.queries.ReadObjectQuery.execute(ReadObjectQuery.java:412)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1126)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2842)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1521)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1503)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1463)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.executeQuery(EntityManagerImpl.java:781)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.findInternal(EntityManagerImpl.java:725)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.find(EntityManagerImpl.java:619)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.find(EntityManagerImpl.java:498)
at org.eclipse.persistence.testing.tests.wdf.jpa1.query.TestDeleteQuery.testDeleteEmployeeWithGivenDepartment(TestDeleteQuery.java:168)
at org.eclipse.persistence.testing.framework.wdf.SkipBugzillaTestRunner.runChild(SkipBugzillaTestRunner.java:178)
at org.eclipse.persistence.testing.framework.wdf.SkipBugzillaTestRunner.runChild(SkipBugzillaTestRunner.java:38)
at org.eclipse.persistence.testing.framework.wdf.SkipBugzillaTestRunner.run(SkipBugzillaTestRunner.java:50)
Comment 2 Tom Ware CLA 2011-06-21 14:32:35 EDT
The same issue exists in trunk, but the tests do not fail because the query occurs on an isolated client session.
Comment 3 Tom Ware CLA 2011-06-21 14:53:09 EDT
Created attachment 198357 [details]
Proposed fix
Comment 4 Tom Ware CLA 2011-06-21 15:31:47 EDT
Created attachment 198358 [details]
updated patch
Comment 5 Tom Ware CLA 2011-06-29 13:29:10 EDT
Fixed in trunk, 2.3.1 and 2.2.1

Trunk change has an additional change to DatabaseCall not required in other streams.

Reviewed By Guy Pelletier
Comment 6 Eclipse Webmaster CLA 2022-06-09 10:29:55 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink