Ability for fine-grained configuration of exclusion of foreign key columns in 
FetchPlan
---------------------------------------------------------------------------------------

                 Key: OPENJPA-701
                 URL: https://issues.apache.org/jira/browse/OPENJPA-701
             Project: OpenJPA
          Issue Type: Improvement
          Components: jdbc, sql
    Affects Versions: 1.1.0
            Reporter: Michael Vorburger
            Priority: Minor


Currently (v1.1.0), "Even when a direct relation is not eagerly fetched, 
OpenJPA selects the foreign key columns and caches the values. This way when 
you do traverse the relation, OpenJPA can often find the related object in its 
cache, or at least avoid joins when loading the related object from the 
database. " 
(http://openjpa.apache.org/docs/latest/ref_guide_fetch.html#ref_guide_fetch_impl)

In a domain model with "wide" classes that have lot's of associations = foreign 
key columns on some tables, under a use case where you KNOW that you will not 
traverse some relations (because you know you'll only access 1-2 of many, 
configured by some upper layer, other getters may not even be available to 
end-code), it would be nice if the FetchPlan API was extended to allow for more 
fine-grained configuration of exclusion / inclusion of foreign key columns.

Design proposal, just an idea, could certainly be implemented differently: For 
backward compatibility, the current behaviour would likely have to stay as is. 
In addition however, a new method named e.g. 
FetchPlan.doNotIncludeAllForeignKeyColumns() [or a more suitable shorter 
name... :)] would cause the plan NOT to select any foreign key column by 
default. Only FK columns that were explicitly added via addField() would then 
be selected; if no fields in the referenced class are specified via another 
addField, then only the originating PK column would be included, if any field 
in the referenced class are also specified, then the JOIN would happen (as 
today - or would this simple API not suffice?). -- Minor: Ideally, an 
addField() for the association and another addField() for only the ID/PK 
attribute of the related class should not lead to a SQL JOIN either, as the 
ID/PK is in the original table of course, even if in the object model it's an 
attribute of the related class.

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

Reply via email to