Issue Details (XML | Word | Printable)

Key: NUCRDBMS-473
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Andy Jefferson
Reporter: Andy Jefferson
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
DataNucleus Store RDBMS

Fetch of FK field selects the FK (in this table), and the PK in the related table. Duplicate information

Created: 22/Nov/10 04:37 PM   Updated: 10/Dec/10 07:49 AM   Resolved: 26/Nov/10 12:41 PM
Component/s: Queries
Affects Version/s: 2.1.0.release, 2.1.1, 2.1.2, 2.1.3, 2.2.0.m1
Fix Version/s: 2.2.0.release


 Description  « Hide
If we have a 1-1 uni from our candidate and we access the field, it sends a FetchRequest to get the related object. This selects the FK (in our candidate table), and then selects the fetch plan fields of the related object (including its PK). Should just omit the select of the FK if also selecting the fetch plan of the related object

Sort Order: Ascending order - Click to sort in descending order
Andy Jefferson added a comment - 26/Nov/10 10:39 AM
An example, see NUCCORE-558 for testcase that generates this

SELECT 'org.datanucleus.test.CircRef' AS NUCLEUS_TYPE,A0.ID AS NUCORDER0,
A0."NEXT",B0.ID,B0."NEXT",B0.PREV,B0.VER,
A0.PREV,C0.ID,C0."NEXT",C0.PREV,C0.VER,
A0.VER

FROM CIRCREF A0
LEFT OUTER JOIN CIRCREF B0 ON A0."NEXT" = B0.ID
LEFT OUTER JOIN CIRCREF C0 ON A0.PREV = C0.ID
ORDER BY NUCORDER0


StatementClassMapping:class=null,member=null,mappings=
[
    {field=0,mapping=mapping: org.datanucleus.store.mapped.mapping.IntegerMapping@59f1bf02 column(s): [2]},
    {field=1,mapping=mapping: org.datanucleus.store.mapped.mapping.PersistableMapping@5978f238 column(s): [3]},
    {field=2,mapping=mapping: org.datanucleus.store.mapped.mapping.PersistableMapping@5833a2d9 column(s): [8]},
    {field=-2,mapping=mapping: org.datanucleus.store.mapped.mapping.VersionLongMapping@2479a4 column(s): [13]},
],
children=
[
    {field=1,mapping=StatementClassMapping:class=org.datanucleus.test.CircRef,member=next,mappings=
        [
            {field=0,mapping=mapping: org.datanucleus.store.mapped.mapping.IntegerMapping@59f1bf02 column(s): [4]},
            {field=1,mapping=mapping: org.datanucleus.store.mapped.mapping.PersistableMapping@5978f238 column(s): [5]},
            {field=2,mapping=mapping: org.datanucleus.store.mapped.mapping.PersistableMapping@5833a2d9 column(s): [6]},
            {field=-2,mapping=mapping: org.datanucleus.store.mapped.mapping.VersionLongMapping@2479a4 column(s): [7]}
        ]},
    {field=2,mapping=StatementClassMapping:class=org.datanucleus.test.CircRef,member=prev,mappings=
        [
            {field=0,mapping=mapping: org.datanucleus.store.mapped.mapping.IntegerMapping@59f1bf02 column(s): [9]},
            {field=1,mapping=mapping: org.datanucleus.store.mapped.mapping.PersistableMapping@5978f238 column(s): [10]},
            {field=2,mapping=mapping: org.datanucleus.store.mapped.mapping.PersistableMapping@5833a2d9 column(s): [11]},
            {field=-2,mapping=mapping: org.datanucleus.store.mapped.mapping.VersionLongMapping@2479a4 column(s): [12]}
        ]}
]

While we need to have the "PersistableMapping" rows in the top section we should just (re)use the column(s) defined for the id of the sub-object

Andy Jefferson added a comment - 26/Nov/10 12:41 PM
SVN trunk now generates

SELECT 'org.datanucleus.test.CircRef' AS NUCLEUS_TYPE, A0.ID AS NUCORDER0,
B0.ID,B0."NEXT",B0.PREV,B0.VER,
C0.ID,C0."NEXT",C0.PREV,C0.VER,
A0.VER
FROM CIRCREF A0
LEFT OUTER JOIN CIRCREF B0 ON A0."NEXT" = B0.ID
LEFT OUTER JOIN CIRCREF C0 ON A0.PREV = C0.ID
ORDER BY NUCORDER0

StatementClassMapping:class=null,member=null,mappings=
[
    {field=0,mapping=mapping: org.datanucleus.store.mapped.mapping.IntegerMapping@5995c31c column(s): [2]},
    {field=1,mapping=mapping: org.datanucleus.store.mapped.mapping.PersistableMapping@5947d51d column(s): [3]},
    {field=2,mapping=mapping: org.datanucleus.store.mapped.mapping.PersistableMapping@585e7d87 column(s): [7]},
    {field=-2,mapping=mapping: org.datanucleus.store.mapped.mapping.VersionLongMapping@ce796 column(s): [11]},
],
children=
[
    {field=1,mapping=StatementClassMapping:class=org.datanucleus.test.CircRef,member=next,mappings=
        [
            {field=0,mapping=mapping: org.datanucleus.store.mapped.mapping.IntegerMapping@5995c31c column(s): [3]},
            {field=1,mapping=mapping: org.datanucleus.store.mapped.mapping.PersistableMapping@5947d51d column(s): [4]},
            {field=2,mapping=mapping: org.datanucleus.store.mapped.mapping.PersistableMapping@585e7d87 column(s): [5]},
            {field=-2,mapping=mapping: org.datanucleus.store.mapped.mapping.VersionLongMapping@ce796 column(s): [6]}
        ]},
    {field=2,mapping=StatementClassMapping:class=org.datanucleus.test.CircRef,member=prev,mappings=
        [
            {field=0,mapping=mapping: org.datanucleus.store.mapped.mapping.IntegerMapping@5995c31c column(s): [7]},
            {field=1,mapping=mapping: org.datanucleus.store.mapped.mapping.PersistableMapping@5947d51d column(s): [8]},
            {field=2,mapping=mapping: org.datanucleus.store.mapped.mapping.PersistableMapping@585e7d87 column(s): [9]},
            {field=-2,mapping=mapping: org.datanucleus.store.mapped.mapping.VersionLongMapping@ce796 column(s): [10]}
        ]}
]