You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Ravi P Palacherla (JIRA)" <ji...@apache.org> on 2009/07/10 19:03:15 UTC

[jira] Created: (OPENJPA-1174) OpenJPA performs differently with orm.xml and annotations

OpenJPA performs differently with orm.xml and annotations
---------------------------------------------------------

                 Key: OPENJPA-1174
                 URL: https://issues.apache.org/jira/browse/OPENJPA-1174
             Project: OpenJPA
          Issue Type: Bug
    Affects Versions: 2.0.0
            Reporter: Ravi P Palacherla
            Assignee: Ravi P Palacherla


 When configurations are provided from orm.xml file, some behaviors are different from behaviors on annotation configuration. 
The behavior difference occurs when fetch=LAZY is specified on many-to-one mapping.

When there are two objects Country and Security and Security has many-to-one mapping field country, 
OpenJPA executes one more SQL query to get country field if orm.xml file is used.

 ----
 * annotation case

     // step 1) Load country in entity manager
     aUS_country = t.em.find(Country.class, aUS_sid);
     // SELECT t0.NAME FROM TEST16.COUNTRY t0 WHERE t0.COUNTRY_ID = ?

     // step 2) Load security in entity manager
     aI_security = t.em.find(Security.class, aI_sid);
     // SELECT t0.COUNTRY_ID, t0.SYMBOL FROM TEST19.SECURITY t0 WHERE t0.SECURITY_ID = ?

     // step 3) get country from security
     Country aUS_country2 = aI_security.getCountry();
     // no SQL was executed.
 .
 * orm.xml case
 .
     // step 1) Load country in entity manager
     aUS_country = t.em.find(Country.class, aUS_sid);
     // SELECT t0.NAME FROM TEST16.COUNTRY t0 WHERE t0.COUNTRY_ID = ?
 .
     // step 2) Load security in entity manager
     aI_security = t.em.find(Security.class, aI_sid);
     // SELECT t0.SYMBOL FROM TEST16.SECURITY t0 WHERE t0.SECURITY_ID = ?
 .
     // step 3) get country from security
     Country aUS_country2 = aI_security.getCountry();
     // SELECT t1.COUNTRY_ID, t1.NAME   FROM TEST16.SECURITY t0, TEST16.COUNTRY t1 WHERE t0.SECURITY_ID = ? AND t0.COUNTRY_ID = t1.COUNTRY_ID
 ----

 The important difference is in step 2. When using orm.xml, many-to-one field "country" was not loaded if fetch=LAZY.
 Instead, it's loaded on annotation configuration.
 .
 Because many-to-one "country" field is not loaded, step 3 executes additional SQL to load "country" field on orm.xml.
 Instead, on annotation case, step 3 did not execute any SQLs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (OPENJPA-1174) OpenJPA performs differently with orm.xml and annotations

Posted by "Michael Dick (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-1174?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Dick updated OPENJPA-1174:
----------------------------------

    Remaining Estimate: 0h
     Original Estimate: 0h

Hi Ravi, the new patch looks good. I'm running the regression bucket now (not expecting anything just a sanity check). The only change I had to make was to reorder tags in orm.xml (m2m must come before embedded). Not sure how anyone would notice that but the IBM SDK happens to check it.. 

> OpenJPA performs differently with orm.xml and annotations
> ---------------------------------------------------------
>
>                 Key: OPENJPA-1174
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1174
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.0.0
>            Reporter: Ravi P Palacherla
>            Assignee: Ravi P Palacherla
>         Attachments: OPENJPA-1174-trunk.patch, OPENJPA-1174-trunk.patch
>
>   Original Estimate: 0h
>  Remaining Estimate: 0h
>
>  When configurations are provided from orm.xml file, some behaviors are different from behaviors on annotation configuration. 
> The behavior difference occurs when fetch=LAZY is specified on many-to-one mapping.
> When there are two objects Country and Security and Security has many-to-one mapping field country, 
> OpenJPA executes one more SQL query to get country field if orm.xml file is used.
>  ----
>  * annotation case
>      // step 1) Load country in entity manager
>      aUS_country = t.em.find(Country.class, aUS_sid);
>      // SELECT t0.NAME FROM TEST16.COUNTRY t0 WHERE t0.COUNTRY_ID = ?
>      // step 2) Load security in entity manager
>      aI_security = t.em.find(Security.class, aI_sid);
>      // SELECT t0.COUNTRY_ID, t0.SYMBOL FROM TEST19.SECURITY t0 WHERE t0.SECURITY_ID = ?
>      // step 3) get country from security
>      Country aUS_country2 = aI_security.getCountry();
>      // no SQL was executed.
>  .
>  * orm.xml case
>  .
>      // step 1) Load country in entity manager
>      aUS_country = t.em.find(Country.class, aUS_sid);
>      // SELECT t0.NAME FROM TEST16.COUNTRY t0 WHERE t0.COUNTRY_ID = ?
>  .
>      // step 2) Load security in entity manager
>      aI_security = t.em.find(Security.class, aI_sid);
>      // SELECT t0.SYMBOL FROM TEST16.SECURITY t0 WHERE t0.SECURITY_ID = ?
>  .
>      // step 3) get country from security
>      Country aUS_country2 = aI_security.getCountry();
>      // SELECT t1.COUNTRY_ID, t1.NAME   FROM TEST16.SECURITY t0, TEST16.COUNTRY t1 WHERE t0.SECURITY_ID = ? AND t0.COUNTRY_ID = t1.COUNTRY_ID
>  ----
>  The important difference is in step 2. When using orm.xml, many-to-one field "country" was not loaded if fetch=LAZY.
>  Instead, it's loaded on annotation configuration.
>  .
>  Because many-to-one "country" field is not loaded, step 3 executes additional SQL to load "country" field on orm.xml.
>  Instead, on annotation case, step 3 did not execute any SQLs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (OPENJPA-1174) OpenJPA performs differently with orm.xml and annotations

Posted by "David Ezzio (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-1174?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Ezzio updated OPENJPA-1174:
---------------------------------

    Fix Version/s: 1.1.1

Merged fix at trunk revision 799754 to 1.1.x branch at revision 802838

> OpenJPA performs differently with orm.xml and annotations
> ---------------------------------------------------------
>
>                 Key: OPENJPA-1174
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1174
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 2.0.0
>            Reporter: Ravi P Palacherla
>            Assignee: Ravi P Palacherla
>             Fix For: 1.1.1, 2.0.0-M3
>
>         Attachments: OPENJPA-1174-trunk.patch, OPENJPA-1174-trunk.patch
>
>   Original Estimate: 0h
>  Remaining Estimate: 0h
>
>  When configurations are provided from orm.xml file, some behaviors are different from behaviors on annotation configuration. 
> The behavior difference occurs when fetch=LAZY is specified on many-to-one mapping.
> When there are two objects Country and Security and Security has many-to-one mapping field country, 
> OpenJPA executes one more SQL query to get country field if orm.xml file is used.
>  ----
>  * annotation case
>      // step 1) Load country in entity manager
>      aUS_country = t.em.find(Country.class, aUS_sid);
>      // SELECT t0.NAME FROM TEST16.COUNTRY t0 WHERE t0.COUNTRY_ID = ?
>      // step 2) Load security in entity manager
>      aI_security = t.em.find(Security.class, aI_sid);
>      // SELECT t0.COUNTRY_ID, t0.SYMBOL FROM TEST19.SECURITY t0 WHERE t0.SECURITY_ID = ?
>      // step 3) get country from security
>      Country aUS_country2 = aI_security.getCountry();
>      // no SQL was executed.
>  .
>  * orm.xml case
>  .
>      // step 1) Load country in entity manager
>      aUS_country = t.em.find(Country.class, aUS_sid);
>      // SELECT t0.NAME FROM TEST16.COUNTRY t0 WHERE t0.COUNTRY_ID = ?
>  .
>      // step 2) Load security in entity manager
>      aI_security = t.em.find(Security.class, aI_sid);
>      // SELECT t0.SYMBOL FROM TEST16.SECURITY t0 WHERE t0.SECURITY_ID = ?
>  .
>      // step 3) get country from security
>      Country aUS_country2 = aI_security.getCountry();
>      // SELECT t1.COUNTRY_ID, t1.NAME   FROM TEST16.SECURITY t0, TEST16.COUNTRY t1 WHERE t0.SECURITY_ID = ? AND t0.COUNTRY_ID = t1.COUNTRY_ID
>  ----
>  The important difference is in step 2. When using orm.xml, many-to-one field "country" was not loaded if fetch=LAZY.
>  Instead, it's loaded on annotation configuration.
>  .
>  Because many-to-one "country" field is not loaded, step 3 executes additional SQL to load "country" field on orm.xml.
>  Instead, on annotation case, step 3 did not execute any SQLs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (OPENJPA-1174) OpenJPA performs differently with orm.xml and annotations

Posted by "Michael Dick (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-1174?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Dick resolved OPENJPA-1174.
-----------------------------------

    Resolution: Fixed

> OpenJPA performs differently with orm.xml and annotations
> ---------------------------------------------------------
>
>                 Key: OPENJPA-1174
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1174
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 2.0.0
>            Reporter: Ravi P Palacherla
>            Assignee: Ravi P Palacherla
>             Fix For: 2.0.0
>
>         Attachments: OPENJPA-1174-trunk.patch, OPENJPA-1174-trunk.patch
>
>   Original Estimate: 0h
>  Remaining Estimate: 0h
>
>  When configurations are provided from orm.xml file, some behaviors are different from behaviors on annotation configuration. 
> The behavior difference occurs when fetch=LAZY is specified on many-to-one mapping.
> When there are two objects Country and Security and Security has many-to-one mapping field country, 
> OpenJPA executes one more SQL query to get country field if orm.xml file is used.
>  ----
>  * annotation case
>      // step 1) Load country in entity manager
>      aUS_country = t.em.find(Country.class, aUS_sid);
>      // SELECT t0.NAME FROM TEST16.COUNTRY t0 WHERE t0.COUNTRY_ID = ?
>      // step 2) Load security in entity manager
>      aI_security = t.em.find(Security.class, aI_sid);
>      // SELECT t0.COUNTRY_ID, t0.SYMBOL FROM TEST19.SECURITY t0 WHERE t0.SECURITY_ID = ?
>      // step 3) get country from security
>      Country aUS_country2 = aI_security.getCountry();
>      // no SQL was executed.
>  .
>  * orm.xml case
>  .
>      // step 1) Load country in entity manager
>      aUS_country = t.em.find(Country.class, aUS_sid);
>      // SELECT t0.NAME FROM TEST16.COUNTRY t0 WHERE t0.COUNTRY_ID = ?
>  .
>      // step 2) Load security in entity manager
>      aI_security = t.em.find(Security.class, aI_sid);
>      // SELECT t0.SYMBOL FROM TEST16.SECURITY t0 WHERE t0.SECURITY_ID = ?
>  .
>      // step 3) get country from security
>      Country aUS_country2 = aI_security.getCountry();
>      // SELECT t1.COUNTRY_ID, t1.NAME   FROM TEST16.SECURITY t0, TEST16.COUNTRY t1 WHERE t0.SECURITY_ID = ? AND t0.COUNTRY_ID = t1.COUNTRY_ID
>  ----
>  The important difference is in step 2. When using orm.xml, many-to-one field "country" was not loaded if fetch=LAZY.
>  Instead, it's loaded on annotation configuration.
>  .
>  Because many-to-one "country" field is not loaded, step 3 executes additional SQL to load "country" field on orm.xml.
>  Instead, on annotation case, step 3 did not execute any SQLs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (OPENJPA-1174) OpenJPA performs differently with orm.xml and annotations

Posted by "Ravi P Palacherla (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-1174?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ravi P Palacherla updated OPENJPA-1174:
---------------------------------------

    Attachment: OPENJPA-1174-trunk.patch

Attached patch file contains the testcase and fix.

Please comment after reviewing the changes.

Regards,
Ravi.

> OpenJPA performs differently with orm.xml and annotations
> ---------------------------------------------------------
>
>                 Key: OPENJPA-1174
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1174
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.0.0
>            Reporter: Ravi P Palacherla
>            Assignee: Ravi P Palacherla
>         Attachments: OPENJPA-1174-trunk.patch
>
>
>  When configurations are provided from orm.xml file, some behaviors are different from behaviors on annotation configuration. 
> The behavior difference occurs when fetch=LAZY is specified on many-to-one mapping.
> When there are two objects Country and Security and Security has many-to-one mapping field country, 
> OpenJPA executes one more SQL query to get country field if orm.xml file is used.
>  ----
>  * annotation case
>      // step 1) Load country in entity manager
>      aUS_country = t.em.find(Country.class, aUS_sid);
>      // SELECT t0.NAME FROM TEST16.COUNTRY t0 WHERE t0.COUNTRY_ID = ?
>      // step 2) Load security in entity manager
>      aI_security = t.em.find(Security.class, aI_sid);
>      // SELECT t0.COUNTRY_ID, t0.SYMBOL FROM TEST19.SECURITY t0 WHERE t0.SECURITY_ID = ?
>      // step 3) get country from security
>      Country aUS_country2 = aI_security.getCountry();
>      // no SQL was executed.
>  .
>  * orm.xml case
>  .
>      // step 1) Load country in entity manager
>      aUS_country = t.em.find(Country.class, aUS_sid);
>      // SELECT t0.NAME FROM TEST16.COUNTRY t0 WHERE t0.COUNTRY_ID = ?
>  .
>      // step 2) Load security in entity manager
>      aI_security = t.em.find(Security.class, aI_sid);
>      // SELECT t0.SYMBOL FROM TEST16.SECURITY t0 WHERE t0.SECURITY_ID = ?
>  .
>      // step 3) get country from security
>      Country aUS_country2 = aI_security.getCountry();
>      // SELECT t1.COUNTRY_ID, t1.NAME   FROM TEST16.SECURITY t0, TEST16.COUNTRY t1 WHERE t0.SECURITY_ID = ? AND t0.COUNTRY_ID = t1.COUNTRY_ID
>  ----
>  The important difference is in step 2. When using orm.xml, many-to-one field "country" was not loaded if fetch=LAZY.
>  Instead, it's loaded on annotation configuration.
>  .
>  Because many-to-one "country" field is not loaded, step 3 executes additional SQL to load "country" field on orm.xml.
>  Instead, on annotation case, step 3 did not execute any SQLs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (OPENJPA-1174) OpenJPA performs differently with orm.xml and annotations

Posted by "Ravi P Palacherla (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-1174?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ravi P Palacherla updated OPENJPA-1174:
---------------------------------------

    Attachment: OPENJPA-1174-trunk.patch

Hi Mike,

Attached patch contains new testcase.
This time it compared SQL generated from annotation processing with mapping file processing.

Please review it and let me know of any changes.

Regards,
Ravi.

> OpenJPA performs differently with orm.xml and annotations
> ---------------------------------------------------------
>
>                 Key: OPENJPA-1174
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1174
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.0.0
>            Reporter: Ravi P Palacherla
>            Assignee: Ravi P Palacherla
>         Attachments: OPENJPA-1174-trunk.patch, OPENJPA-1174-trunk.patch
>
>
>  When configurations are provided from orm.xml file, some behaviors are different from behaviors on annotation configuration. 
> The behavior difference occurs when fetch=LAZY is specified on many-to-one mapping.
> When there are two objects Country and Security and Security has many-to-one mapping field country, 
> OpenJPA executes one more SQL query to get country field if orm.xml file is used.
>  ----
>  * annotation case
>      // step 1) Load country in entity manager
>      aUS_country = t.em.find(Country.class, aUS_sid);
>      // SELECT t0.NAME FROM TEST16.COUNTRY t0 WHERE t0.COUNTRY_ID = ?
>      // step 2) Load security in entity manager
>      aI_security = t.em.find(Security.class, aI_sid);
>      // SELECT t0.COUNTRY_ID, t0.SYMBOL FROM TEST19.SECURITY t0 WHERE t0.SECURITY_ID = ?
>      // step 3) get country from security
>      Country aUS_country2 = aI_security.getCountry();
>      // no SQL was executed.
>  .
>  * orm.xml case
>  .
>      // step 1) Load country in entity manager
>      aUS_country = t.em.find(Country.class, aUS_sid);
>      // SELECT t0.NAME FROM TEST16.COUNTRY t0 WHERE t0.COUNTRY_ID = ?
>  .
>      // step 2) Load security in entity manager
>      aI_security = t.em.find(Security.class, aI_sid);
>      // SELECT t0.SYMBOL FROM TEST16.SECURITY t0 WHERE t0.SECURITY_ID = ?
>  .
>      // step 3) get country from security
>      Country aUS_country2 = aI_security.getCountry();
>      // SELECT t1.COUNTRY_ID, t1.NAME   FROM TEST16.SECURITY t0, TEST16.COUNTRY t1 WHERE t0.SECURITY_ID = ? AND t0.COUNTRY_ID = t1.COUNTRY_ID
>  ----
>  The important difference is in step 2. When using orm.xml, many-to-one field "country" was not loaded if fetch=LAZY.
>  Instead, it's loaded on annotation configuration.
>  .
>  Because many-to-one "country" field is not loaded, step 3 executes additional SQL to load "country" field on orm.xml.
>  Instead, on annotation case, step 3 did not execute any SQLs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (OPENJPA-1174) OpenJPA performs differently with orm.xml and annotations

Posted by "Michael Dick (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-1174?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Dick updated OPENJPA-1174:
----------------------------------

      Component/s: jpa
    Fix Version/s: 2.0.0

Thanks for the patch and all the work debugging Ravi. 

Committed in revision 799754

> OpenJPA performs differently with orm.xml and annotations
> ---------------------------------------------------------
>
>                 Key: OPENJPA-1174
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1174
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 2.0.0
>            Reporter: Ravi P Palacherla
>            Assignee: Ravi P Palacherla
>             Fix For: 2.0.0
>
>         Attachments: OPENJPA-1174-trunk.patch, OPENJPA-1174-trunk.patch
>
>   Original Estimate: 0h
>  Remaining Estimate: 0h
>
>  When configurations are provided from orm.xml file, some behaviors are different from behaviors on annotation configuration. 
> The behavior difference occurs when fetch=LAZY is specified on many-to-one mapping.
> When there are two objects Country and Security and Security has many-to-one mapping field country, 
> OpenJPA executes one more SQL query to get country field if orm.xml file is used.
>  ----
>  * annotation case
>      // step 1) Load country in entity manager
>      aUS_country = t.em.find(Country.class, aUS_sid);
>      // SELECT t0.NAME FROM TEST16.COUNTRY t0 WHERE t0.COUNTRY_ID = ?
>      // step 2) Load security in entity manager
>      aI_security = t.em.find(Security.class, aI_sid);
>      // SELECT t0.COUNTRY_ID, t0.SYMBOL FROM TEST19.SECURITY t0 WHERE t0.SECURITY_ID = ?
>      // step 3) get country from security
>      Country aUS_country2 = aI_security.getCountry();
>      // no SQL was executed.
>  .
>  * orm.xml case
>  .
>      // step 1) Load country in entity manager
>      aUS_country = t.em.find(Country.class, aUS_sid);
>      // SELECT t0.NAME FROM TEST16.COUNTRY t0 WHERE t0.COUNTRY_ID = ?
>  .
>      // step 2) Load security in entity manager
>      aI_security = t.em.find(Security.class, aI_sid);
>      // SELECT t0.SYMBOL FROM TEST16.SECURITY t0 WHERE t0.SECURITY_ID = ?
>  .
>      // step 3) get country from security
>      Country aUS_country2 = aI_security.getCountry();
>      // SELECT t1.COUNTRY_ID, t1.NAME   FROM TEST16.SECURITY t0, TEST16.COUNTRY t1 WHERE t0.SECURITY_ID = ? AND t0.COUNTRY_ID = t1.COUNTRY_ID
>  ----
>  The important difference is in step 2. When using orm.xml, many-to-one field "country" was not loaded if fetch=LAZY.
>  Instead, it's loaded on annotation configuration.
>  .
>  Because many-to-one "country" field is not loaded, step 3 executes additional SQL to load "country" field on orm.xml.
>  Instead, on annotation case, step 3 did not execute any SQLs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-1174) OpenJPA performs differently with orm.xml and annotations

Posted by "Ravi P Palacherla (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-1174?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12731529#action_12731529 ] 

Ravi P Palacherla commented on OPENJPA-1174:
--------------------------------------------

Hi Mike,

Thanks for looking into it.

The current testcase attached just shows how it is handled in case of mapping file.
Are you looking for a testcase that shows the differences between annotation handling and mapping file?
Please confirm and I will start working on it.

Regards,
Ravi.





> OpenJPA performs differently with orm.xml and annotations
> ---------------------------------------------------------
>
>                 Key: OPENJPA-1174
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1174
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.0.0
>            Reporter: Ravi P Palacherla
>            Assignee: Ravi P Palacherla
>         Attachments: OPENJPA-1174-trunk.patch
>
>
>  When configurations are provided from orm.xml file, some behaviors are different from behaviors on annotation configuration. 
> The behavior difference occurs when fetch=LAZY is specified on many-to-one mapping.
> When there are two objects Country and Security and Security has many-to-one mapping field country, 
> OpenJPA executes one more SQL query to get country field if orm.xml file is used.
>  ----
>  * annotation case
>      // step 1) Load country in entity manager
>      aUS_country = t.em.find(Country.class, aUS_sid);
>      // SELECT t0.NAME FROM TEST16.COUNTRY t0 WHERE t0.COUNTRY_ID = ?
>      // step 2) Load security in entity manager
>      aI_security = t.em.find(Security.class, aI_sid);
>      // SELECT t0.COUNTRY_ID, t0.SYMBOL FROM TEST19.SECURITY t0 WHERE t0.SECURITY_ID = ?
>      // step 3) get country from security
>      Country aUS_country2 = aI_security.getCountry();
>      // no SQL was executed.
>  .
>  * orm.xml case
>  .
>      // step 1) Load country in entity manager
>      aUS_country = t.em.find(Country.class, aUS_sid);
>      // SELECT t0.NAME FROM TEST16.COUNTRY t0 WHERE t0.COUNTRY_ID = ?
>  .
>      // step 2) Load security in entity manager
>      aI_security = t.em.find(Security.class, aI_sid);
>      // SELECT t0.SYMBOL FROM TEST16.SECURITY t0 WHERE t0.SECURITY_ID = ?
>  .
>      // step 3) get country from security
>      Country aUS_country2 = aI_security.getCountry();
>      // SELECT t1.COUNTRY_ID, t1.NAME   FROM TEST16.SECURITY t0, TEST16.COUNTRY t1 WHERE t0.SECURITY_ID = ? AND t0.COUNTRY_ID = t1.COUNTRY_ID
>  ----
>  The important difference is in step 2. When using orm.xml, many-to-one field "country" was not loaded if fetch=LAZY.
>  Instead, it's loaded on annotation configuration.
>  .
>  Because many-to-one "country" field is not loaded, step 3 executes additional SQL to load "country" field on orm.xml.
>  Instead, on annotation case, step 3 did not execute any SQLs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Reopened: (OPENJPA-1174) OpenJPA performs differently with orm.xml and annotations

Posted by "Fay Wang (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-1174?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Fay Wang reopened OPENJPA-1174:
-------------------------------


The default fetch type for ManyToOne and OneToOne is eager. That is, if the fetch type is not specified in the orm.xml, the fetch mode should be eager.

> OpenJPA performs differently with orm.xml and annotations
> ---------------------------------------------------------
>
>                 Key: OPENJPA-1174
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1174
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 2.0.0
>            Reporter: Ravi P Palacherla
>            Assignee: Ravi P Palacherla
>             Fix For: 1.1.1, 2.0.0-M3
>
>         Attachments: OPENJPA-1174-trunk.patch, OPENJPA-1174-trunk.patch
>
>   Original Estimate: 0h
>  Remaining Estimate: 0h
>
>  When configurations are provided from orm.xml file, some behaviors are different from behaviors on annotation configuration. 
> The behavior difference occurs when fetch=LAZY is specified on many-to-one mapping.
> When there are two objects Country and Security and Security has many-to-one mapping field country, 
> OpenJPA executes one more SQL query to get country field if orm.xml file is used.
>  ----
>  * annotation case
>      // step 1) Load country in entity manager
>      aUS_country = t.em.find(Country.class, aUS_sid);
>      // SELECT t0.NAME FROM TEST16.COUNTRY t0 WHERE t0.COUNTRY_ID = ?
>      // step 2) Load security in entity manager
>      aI_security = t.em.find(Security.class, aI_sid);
>      // SELECT t0.COUNTRY_ID, t0.SYMBOL FROM TEST19.SECURITY t0 WHERE t0.SECURITY_ID = ?
>      // step 3) get country from security
>      Country aUS_country2 = aI_security.getCountry();
>      // no SQL was executed.
>  .
>  * orm.xml case
>  .
>      // step 1) Load country in entity manager
>      aUS_country = t.em.find(Country.class, aUS_sid);
>      // SELECT t0.NAME FROM TEST16.COUNTRY t0 WHERE t0.COUNTRY_ID = ?
>  .
>      // step 2) Load security in entity manager
>      aI_security = t.em.find(Security.class, aI_sid);
>      // SELECT t0.SYMBOL FROM TEST16.SECURITY t0 WHERE t0.SECURITY_ID = ?
>  .
>      // step 3) get country from security
>      Country aUS_country2 = aI_security.getCountry();
>      // SELECT t1.COUNTRY_ID, t1.NAME   FROM TEST16.SECURITY t0, TEST16.COUNTRY t1 WHERE t0.SECURITY_ID = ? AND t0.COUNTRY_ID = t1.COUNTRY_ID
>  ----
>  The important difference is in step 2. When using orm.xml, many-to-one field "country" was not loaded if fetch=LAZY.
>  Instead, it's loaded on annotation configuration.
>  .
>  Because many-to-one "country" field is not loaded, step 3 executes additional SQL to load "country" field on orm.xml.
>  Instead, on annotation case, step 3 did not execute any SQLs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-1174) OpenJPA performs differently with orm.xml and annotations

Posted by "Michael Dick (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-1174?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12731603#action_12731603 ] 

Michael Dick commented on OPENJPA-1174:
---------------------------------------

Hi Ravi,

Here's the portion of the patch that I'm talking about :

@@ -1393,6 +1398,7 @@

     protected void parseEmbedded(FieldMetaData fmd, Attributes attrs)
         throws SAXException {
         assertPC(fmd, "Embedded");
+        fmd.setInDefaultFetchGroup(true);
         fmd.setEmbedded(true);
         fmd.setSerialized(false); // override any Lob annotation

This is the only method in XMLPesistenceMetaDataParser that doesn't have a check like this one : 
                String val = attrs.getValue("fetch");
                if (val != null) {
                    fmd.setInDefaultFetchGroup("EAGER".equals(val));
                }

With this change we won't be checking the fetch value for Embedded fields. It matches the annotation parser, but we should add a testcase with an Embedded field to demonstrate the change in behavior. 

Actually it might be worth spending a few cycles on developing lower level unit test that validates that the annotations & xml are handled identically, but that's beyond the scope of this issue really. 

> OpenJPA performs differently with orm.xml and annotations
> ---------------------------------------------------------
>
>                 Key: OPENJPA-1174
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1174
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.0.0
>            Reporter: Ravi P Palacherla
>            Assignee: Ravi P Palacherla
>         Attachments: OPENJPA-1174-trunk.patch
>
>
>  When configurations are provided from orm.xml file, some behaviors are different from behaviors on annotation configuration. 
> The behavior difference occurs when fetch=LAZY is specified on many-to-one mapping.
> When there are two objects Country and Security and Security has many-to-one mapping field country, 
> OpenJPA executes one more SQL query to get country field if orm.xml file is used.
>  ----
>  * annotation case
>      // step 1) Load country in entity manager
>      aUS_country = t.em.find(Country.class, aUS_sid);
>      // SELECT t0.NAME FROM TEST16.COUNTRY t0 WHERE t0.COUNTRY_ID = ?
>      // step 2) Load security in entity manager
>      aI_security = t.em.find(Security.class, aI_sid);
>      // SELECT t0.COUNTRY_ID, t0.SYMBOL FROM TEST19.SECURITY t0 WHERE t0.SECURITY_ID = ?
>      // step 3) get country from security
>      Country aUS_country2 = aI_security.getCountry();
>      // no SQL was executed.
>  .
>  * orm.xml case
>  .
>      // step 1) Load country in entity manager
>      aUS_country = t.em.find(Country.class, aUS_sid);
>      // SELECT t0.NAME FROM TEST16.COUNTRY t0 WHERE t0.COUNTRY_ID = ?
>  .
>      // step 2) Load security in entity manager
>      aI_security = t.em.find(Security.class, aI_sid);
>      // SELECT t0.SYMBOL FROM TEST16.SECURITY t0 WHERE t0.SECURITY_ID = ?
>  .
>      // step 3) get country from security
>      Country aUS_country2 = aI_security.getCountry();
>      // SELECT t1.COUNTRY_ID, t1.NAME   FROM TEST16.SECURITY t0, TEST16.COUNTRY t1 WHERE t0.SECURITY_ID = ? AND t0.COUNTRY_ID = t1.COUNTRY_ID
>  ----
>  The important difference is in step 2. When using orm.xml, many-to-one field "country" was not loaded if fetch=LAZY.
>  Instead, it's loaded on annotation configuration.
>  .
>  Because many-to-one "country" field is not loaded, step 3 executes additional SQL to load "country" field on orm.xml.
>  Instead, on annotation case, step 3 did not execute any SQLs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-1174) OpenJPA performs differently with orm.xml and annotations

Posted by "Michael Dick (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-1174?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12731511#action_12731511 ] 

Michael Dick commented on OPENJPA-1174:
---------------------------------------

Thanks for the patch Ravi. I noticed that you also updated how we handle embeddables when specified in a mapping file. They're now included in the default fetch group automatically. 

It matches the annotation handling and it's a great catch but we probably should add a testcase for it (unless I've missed where it's covered). 

The patch looks good though - running regression tests now. 

> OpenJPA performs differently with orm.xml and annotations
> ---------------------------------------------------------
>
>                 Key: OPENJPA-1174
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1174
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.0.0
>            Reporter: Ravi P Palacherla
>            Assignee: Ravi P Palacherla
>         Attachments: OPENJPA-1174-trunk.patch
>
>
>  When configurations are provided from orm.xml file, some behaviors are different from behaviors on annotation configuration. 
> The behavior difference occurs when fetch=LAZY is specified on many-to-one mapping.
> When there are two objects Country and Security and Security has many-to-one mapping field country, 
> OpenJPA executes one more SQL query to get country field if orm.xml file is used.
>  ----
>  * annotation case
>      // step 1) Load country in entity manager
>      aUS_country = t.em.find(Country.class, aUS_sid);
>      // SELECT t0.NAME FROM TEST16.COUNTRY t0 WHERE t0.COUNTRY_ID = ?
>      // step 2) Load security in entity manager
>      aI_security = t.em.find(Security.class, aI_sid);
>      // SELECT t0.COUNTRY_ID, t0.SYMBOL FROM TEST19.SECURITY t0 WHERE t0.SECURITY_ID = ?
>      // step 3) get country from security
>      Country aUS_country2 = aI_security.getCountry();
>      // no SQL was executed.
>  .
>  * orm.xml case
>  .
>      // step 1) Load country in entity manager
>      aUS_country = t.em.find(Country.class, aUS_sid);
>      // SELECT t0.NAME FROM TEST16.COUNTRY t0 WHERE t0.COUNTRY_ID = ?
>  .
>      // step 2) Load security in entity manager
>      aI_security = t.em.find(Security.class, aI_sid);
>      // SELECT t0.SYMBOL FROM TEST16.SECURITY t0 WHERE t0.SECURITY_ID = ?
>  .
>      // step 3) get country from security
>      Country aUS_country2 = aI_security.getCountry();
>      // SELECT t1.COUNTRY_ID, t1.NAME   FROM TEST16.SECURITY t0, TEST16.COUNTRY t1 WHERE t0.SECURITY_ID = ? AND t0.COUNTRY_ID = t1.COUNTRY_ID
>  ----
>  The important difference is in step 2. When using orm.xml, many-to-one field "country" was not loaded if fetch=LAZY.
>  Instead, it's loaded on annotation configuration.
>  .
>  Because many-to-one "country" field is not loaded, step 3 executes additional SQL to load "country" field on orm.xml.
>  Instead, on annotation case, step 3 did not execute any SQLs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (OPENJPA-1174) OpenJPA performs differently with orm.xml and annotations

Posted by "Ravi P Palacherla (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-1174?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ravi P Palacherla updated OPENJPA-1174:
---------------------------------------

    Patch Info: [Patch Available]

> OpenJPA performs differently with orm.xml and annotations
> ---------------------------------------------------------
>
>                 Key: OPENJPA-1174
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1174
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.0.0
>            Reporter: Ravi P Palacherla
>            Assignee: Ravi P Palacherla
>         Attachments: OPENJPA-1174-trunk.patch
>
>
>  When configurations are provided from orm.xml file, some behaviors are different from behaviors on annotation configuration. 
> The behavior difference occurs when fetch=LAZY is specified on many-to-one mapping.
> When there are two objects Country and Security and Security has many-to-one mapping field country, 
> OpenJPA executes one more SQL query to get country field if orm.xml file is used.
>  ----
>  * annotation case
>      // step 1) Load country in entity manager
>      aUS_country = t.em.find(Country.class, aUS_sid);
>      // SELECT t0.NAME FROM TEST16.COUNTRY t0 WHERE t0.COUNTRY_ID = ?
>      // step 2) Load security in entity manager
>      aI_security = t.em.find(Security.class, aI_sid);
>      // SELECT t0.COUNTRY_ID, t0.SYMBOL FROM TEST19.SECURITY t0 WHERE t0.SECURITY_ID = ?
>      // step 3) get country from security
>      Country aUS_country2 = aI_security.getCountry();
>      // no SQL was executed.
>  .
>  * orm.xml case
>  .
>      // step 1) Load country in entity manager
>      aUS_country = t.em.find(Country.class, aUS_sid);
>      // SELECT t0.NAME FROM TEST16.COUNTRY t0 WHERE t0.COUNTRY_ID = ?
>  .
>      // step 2) Load security in entity manager
>      aI_security = t.em.find(Security.class, aI_sid);
>      // SELECT t0.SYMBOL FROM TEST16.SECURITY t0 WHERE t0.SECURITY_ID = ?
>  .
>      // step 3) get country from security
>      Country aUS_country2 = aI_security.getCountry();
>      // SELECT t1.COUNTRY_ID, t1.NAME   FROM TEST16.SECURITY t0, TEST16.COUNTRY t1 WHERE t0.SECURITY_ID = ? AND t0.COUNTRY_ID = t1.COUNTRY_ID
>  ----
>  The important difference is in step 2. When using orm.xml, many-to-one field "country" was not loaded if fetch=LAZY.
>  Instead, it's loaded on annotation configuration.
>  .
>  Because many-to-one "country" field is not loaded, step 3 executes additional SQL to load "country" field on orm.xml.
>  Instead, on annotation case, step 3 did not execute any SQLs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-1174) OpenJPA performs differently with orm.xml and annotations

Posted by "Michael Dick (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-1174?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12731618#action_12731618 ] 

Michael Dick commented on OPENJPA-1174:
---------------------------------------

Actually in thinking about this more I think the testcase needs to be reconsidered. What we're really interested in here is whether the metedata is generated identically when we use an xml mapping file or annotations. We're not particularly interested in whether we ignore FetchType=LAZY - so long as we do it identically either way the MetaData is obtained. 

The testcase relies on the LAZY hint being ignored (it's actually very interesting that it isn't ignored if no hint is specified). This behavior can't be relied on and wouldn't be expected in most cases. We could change this behavior at any point in the future and this testcase would no longer serve the intended purpose. 

A better functional test would be to have duplicates of the entities : one with annotations one with orm.xml and make sure the same SQL is issued for both of them. A better unit test could just look at the ClassMetaData / ClassMapping for the two entities and make sure they are equivalent.

In addition we'll want to add an Embedded field in the entities since there's a specific change to parseEmbedded that needs to be asserted. 

While the code changes look correct I'd prefer to validate it with a more reliable unit test. 


> OpenJPA performs differently with orm.xml and annotations
> ---------------------------------------------------------
>
>                 Key: OPENJPA-1174
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1174
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.0.0
>            Reporter: Ravi P Palacherla
>            Assignee: Ravi P Palacherla
>         Attachments: OPENJPA-1174-trunk.patch
>
>
>  When configurations are provided from orm.xml file, some behaviors are different from behaviors on annotation configuration. 
> The behavior difference occurs when fetch=LAZY is specified on many-to-one mapping.
> When there are two objects Country and Security and Security has many-to-one mapping field country, 
> OpenJPA executes one more SQL query to get country field if orm.xml file is used.
>  ----
>  * annotation case
>      // step 1) Load country in entity manager
>      aUS_country = t.em.find(Country.class, aUS_sid);
>      // SELECT t0.NAME FROM TEST16.COUNTRY t0 WHERE t0.COUNTRY_ID = ?
>      // step 2) Load security in entity manager
>      aI_security = t.em.find(Security.class, aI_sid);
>      // SELECT t0.COUNTRY_ID, t0.SYMBOL FROM TEST19.SECURITY t0 WHERE t0.SECURITY_ID = ?
>      // step 3) get country from security
>      Country aUS_country2 = aI_security.getCountry();
>      // no SQL was executed.
>  .
>  * orm.xml case
>  .
>      // step 1) Load country in entity manager
>      aUS_country = t.em.find(Country.class, aUS_sid);
>      // SELECT t0.NAME FROM TEST16.COUNTRY t0 WHERE t0.COUNTRY_ID = ?
>  .
>      // step 2) Load security in entity manager
>      aI_security = t.em.find(Security.class, aI_sid);
>      // SELECT t0.SYMBOL FROM TEST16.SECURITY t0 WHERE t0.SECURITY_ID = ?
>  .
>      // step 3) get country from security
>      Country aUS_country2 = aI_security.getCountry();
>      // SELECT t1.COUNTRY_ID, t1.NAME   FROM TEST16.SECURITY t0, TEST16.COUNTRY t1 WHERE t0.SECURITY_ID = ? AND t0.COUNTRY_ID = t1.COUNTRY_ID
>  ----
>  The important difference is in step 2. When using orm.xml, many-to-one field "country" was not loaded if fetch=LAZY.
>  Instead, it's loaded on annotation configuration.
>  .
>  Because many-to-one "country" field is not loaded, step 3 executes additional SQL to load "country" field on orm.xml.
>  Instead, on annotation case, step 3 did not execute any SQLs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (OPENJPA-1174) OpenJPA performs differently with orm.xml and annotations

Posted by "Fay Wang (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-1174?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Fay Wang resolved OPENJPA-1174.
-------------------------------

    Resolution: Fixed

> OpenJPA performs differently with orm.xml and annotations
> ---------------------------------------------------------
>
>                 Key: OPENJPA-1174
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1174
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 2.0.0
>            Reporter: Ravi P Palacherla
>            Assignee: Ravi P Palacherla
>             Fix For: 1.1.1, 2.0.0-M3
>
>         Attachments: OPENJPA-1174-trunk.patch, OPENJPA-1174-trunk.patch
>
>   Original Estimate: 0h
>  Remaining Estimate: 0h
>
>  When configurations are provided from orm.xml file, some behaviors are different from behaviors on annotation configuration. 
> The behavior difference occurs when fetch=LAZY is specified on many-to-one mapping.
> When there are two objects Country and Security and Security has many-to-one mapping field country, 
> OpenJPA executes one more SQL query to get country field if orm.xml file is used.
>  ----
>  * annotation case
>      // step 1) Load country in entity manager
>      aUS_country = t.em.find(Country.class, aUS_sid);
>      // SELECT t0.NAME FROM TEST16.COUNTRY t0 WHERE t0.COUNTRY_ID = ?
>      // step 2) Load security in entity manager
>      aI_security = t.em.find(Security.class, aI_sid);
>      // SELECT t0.COUNTRY_ID, t0.SYMBOL FROM TEST19.SECURITY t0 WHERE t0.SECURITY_ID = ?
>      // step 3) get country from security
>      Country aUS_country2 = aI_security.getCountry();
>      // no SQL was executed.
>  .
>  * orm.xml case
>  .
>      // step 1) Load country in entity manager
>      aUS_country = t.em.find(Country.class, aUS_sid);
>      // SELECT t0.NAME FROM TEST16.COUNTRY t0 WHERE t0.COUNTRY_ID = ?
>  .
>      // step 2) Load security in entity manager
>      aI_security = t.em.find(Security.class, aI_sid);
>      // SELECT t0.SYMBOL FROM TEST16.SECURITY t0 WHERE t0.SECURITY_ID = ?
>  .
>      // step 3) get country from security
>      Country aUS_country2 = aI_security.getCountry();
>      // SELECT t1.COUNTRY_ID, t1.NAME   FROM TEST16.SECURITY t0, TEST16.COUNTRY t1 WHERE t0.SECURITY_ID = ? AND t0.COUNTRY_ID = t1.COUNTRY_ID
>  ----
>  The important difference is in step 2. When using orm.xml, many-to-one field "country" was not loaded if fetch=LAZY.
>  Instead, it's loaded on annotation configuration.
>  .
>  Because many-to-one "country" field is not loaded, step 3 executes additional SQL to load "country" field on orm.xml.
>  Instead, on annotation case, step 3 did not execute any SQLs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.