You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Heath Thomann (JIRA)" <ji...@apache.org> on 2015/08/19 16:39:46 UTC

[jira] [Assigned] (OPENJPA-2586) Incorrect relationship data returned when QueryCache and FetchPlans are used.

     [ https://issues.apache.org/jira/browse/OPENJPA-2586?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Heath Thomann reassigned OPENJPA-2586:
--------------------------------------

    Assignee: Heath Thomann

> Incorrect relationship data returned when QueryCache and FetchPlans are used.
> -----------------------------------------------------------------------------
>
>                 Key: OPENJPA-2586
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2586
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: datacache, jdbc
>    Affects Versions: 2.1.2, 2.2.2, 2.2.1.1, 2.4.1
>            Reporter: Heath Thomann
>            Assignee: Heath Thomann
>            Priority: Critical
>         Attachments: OPENJPA-2586-2.2.x.patch
>
>
> I have found a scenario that the wrong data is returned when the DataCache, QueryCache, and FetchPlans are used.  To explain, take these very simple entities and relationship:
> @Entity
> public class Entity1 {
>     @Id
>     private int id;
>     @OneToOne(fetch = FetchType.LAZY)
>     private Entity2 ent2;
> ........
> @Entity
> public class Entity2 {
>     @Id
>     private Long id;
> ......
> Given these two entities, take this scenario:
> Query q = em.createQuery("Select e1 from Entity1 e1");
> FetchPlan fetchPlan = q.unwrap(OpenJPAQuery.class).getFetchPlan();
> fetchPlan.addField(Entity1.class, "ent2");
> List<Entity1> results = (List<Entity1>) q.getResultList();
> em.clear();
> assertNotNull("No results returned!", results);
> for (Entity1 e1 : results) {
>     assertNotNull("An 'Entity2' should have been returned!", e1.getEnt2());
> }
> With this code, assume the DataCache and QueryCache are both enabled, and assume there is an Entity1 with an Entity2 in the database.  When we execute this code all works fine.  However, if we execute the code back to back using the same EntityManagerFactory, an Entity1 will be returned but its Entity2 will be null!  If on the other hand, we execute the code 3 times in a row, where there is a time lag between the 2nd and 3rd execution greater than the DataCache timeout, the correct data will be returned during the 3rd execution.  This shows that there is a problem when the DataCache, QueryCache, and a FetchPlan are used.  For more details please see the patch I've attached which contains a test to recreate this issue as well as a proposed fix.
> Thanks,
> Heath Thomann



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)