You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Daniel Migowski <dm...@ikoffice.de> on 2007/06/27 11:42:02 UTC
Inheritance type JOINED
Hello Users,
I just tried out the inheritance type JOINED and added the subclass
fetch mode NONE. My first thoughts were, that this would make queries
for the parent class just iterate over the parent table. After examining
the created table i see, that there is no discriminator field (like in
inheritance type SINGLE_TABLE), so OpenJPA has to join all other tables
just to find out about the type of the class (=slow).
Is it possible to add such a field to the parent table so OpenJPA
recognizes it and optimizes its queries? The OpenJPA documentation does
not describe such a behavior, but i think, it does not forbit it either.
Or should i ask this on the dev list?
Thanks in advance,
Daniel Migowski
Re: Inheritance type JOINED
Posted by Patrick Linskey <pl...@gmail.com>.
Is it possible for you to post the schema that you're using and the
SQL that is generated in both cases?
I'd be interested to see more to figure out why setting the subclass
fetch mode to NONE didn't help.
-Patrick
On 6/28/07, Marc Prud'hommeaux <mp...@apache.org> wrote:
> Daniel-
>
> I believe that setting subclass fetch mode to NONE merely says that
> on the initial fetch, don't grab attributes from children. However,
> when the instances are instantiated, we will always try to
> instantiate every field in the fetch group, and since any subclass
> fields weren't in the initial fetch, we go back to the database to
> get the one by one (which, as you have probably observed, is slow).
>
> Your solution, to mark all the subclass fields as being
> FetchMode.LAZY, is the correct (and, AFAIK, the only) way to do it.
>
>
> On Jun 28, 2007, at 12:59 AM, Daniel Migowski wrote:
>
> > Hello Marc,
> >
> > Thanks for your answer, the DiscriminatorColumn is used now and the
> > query does not do the join anymore, but i had to do another trick
> > to get it working, since the subclass FetchMode is not honored. I
> > set it to NONE, but the fields in the subclass are loaded anyway. I
> > could resolve this by setting all fields to FetchMode.LAZY, but i
> > thought setting the subclass fetchmode should be enough.
> >
> > With best regards,
> > Daniel Migowski.
> >
> > Marc Prud'hommeaux schrieb:
> >> Daniel-
> >>
> >> If you manually specify a @DiscriminatorColumn for the class
> >> ( http://openjpa.apache.org/docs/latest/manual/
> >> manual.html#jpa_overview_mapping_discrim ), does it help at all? I
> >> suspect that we might just not have that optimization in place,
> >> but it might be worth a shot.
> >>
> >> On Jun 27, 2007, at 2:42 AM, Daniel Migowski wrote:
> >>
> >>> Hello Users,
> >>>
> >>> I just tried out the inheritance type JOINED and added the
> >>> subclass fetch mode NONE. My first thoughts were, that this would
> >>> make queries for the parent class just iterate over the parent
> >>> table. After examining the created table i see, that there is no
> >>> discriminator field (like in inheritance type SINGLE_TABLE), so
> >>> OpenJPA has to join all other tables just to find out about the
> >>> type of the class (=slow).
> >>>
> >>> Is it possible to add such a field to the parent table so OpenJPA
> >>> recognizes it and optimizes its queries? The OpenJPA
> >>> documentation does not describe such a behavior, but i think, it
> >>> does not forbit it either. Or should i ask this on the dev list?
> >>>
> >>> Thanks in advance,
> >>> Daniel Migowski
>
>
--
Patrick Linskey
202 669 5907
Re: Inheritance type JOINED
Posted by Marc Prud'hommeaux <mp...@apache.org>.
Daniel-
I believe that setting subclass fetch mode to NONE merely says that
on the initial fetch, don't grab attributes from children. However,
when the instances are instantiated, we will always try to
instantiate every field in the fetch group, and since any subclass
fields weren't in the initial fetch, we go back to the database to
get the one by one (which, as you have probably observed, is slow).
Your solution, to mark all the subclass fields as being
FetchMode.LAZY, is the correct (and, AFAIK, the only) way to do it.
On Jun 28, 2007, at 12:59 AM, Daniel Migowski wrote:
> Hello Marc,
>
> Thanks for your answer, the DiscriminatorColumn is used now and the
> query does not do the join anymore, but i had to do another trick
> to get it working, since the subclass FetchMode is not honored. I
> set it to NONE, but the fields in the subclass are loaded anyway. I
> could resolve this by setting all fields to FetchMode.LAZY, but i
> thought setting the subclass fetchmode should be enough.
>
> With best regards,
> Daniel Migowski.
>
> Marc Prud'hommeaux schrieb:
>> Daniel-
>>
>> If you manually specify a @DiscriminatorColumn for the class
>> ( http://openjpa.apache.org/docs/latest/manual/
>> manual.html#jpa_overview_mapping_discrim ), does it help at all? I
>> suspect that we might just not have that optimization in place,
>> but it might be worth a shot.
>>
>> On Jun 27, 2007, at 2:42 AM, Daniel Migowski wrote:
>>
>>> Hello Users,
>>>
>>> I just tried out the inheritance type JOINED and added the
>>> subclass fetch mode NONE. My first thoughts were, that this would
>>> make queries for the parent class just iterate over the parent
>>> table. After examining the created table i see, that there is no
>>> discriminator field (like in inheritance type SINGLE_TABLE), so
>>> OpenJPA has to join all other tables just to find out about the
>>> type of the class (=slow).
>>>
>>> Is it possible to add such a field to the parent table so OpenJPA
>>> recognizes it and optimizes its queries? The OpenJPA
>>> documentation does not describe such a behavior, but i think, it
>>> does not forbit it either. Or should i ask this on the dev list?
>>>
>>> Thanks in advance,
>>> Daniel Migowski
Re: Inheritance type JOINED
Posted by Daniel Migowski <dm...@ikoffice.de>.
Hello Marc,
Thanks for your answer, the DiscriminatorColumn is used now and the
query does not do the join anymore, but i had to do another trick to get
it working, since the subclass FetchMode is not honored. I set it to
NONE, but the fields in the subclass are loaded anyway. I could resolve
this by setting all fields to FetchMode.LAZY, but i thought setting the
subclass fetchmode should be enough.
With best regards,
Daniel Migowski.
Marc Prud'hommeaux schrieb:
> Daniel-
>
> If you manually specify a @DiscriminatorColumn for the class (
> http://openjpa.apache.org/docs/latest/manual/manual.html#jpa_overview_mapping_discrim
> ), does it help at all? I suspect that we might just not have that
> optimization in place, but it might be worth a shot.
>
> On Jun 27, 2007, at 2:42 AM, Daniel Migowski wrote:
>
>> Hello Users,
>>
>> I just tried out the inheritance type JOINED and added the subclass
>> fetch mode NONE. My first thoughts were, that this would make queries
>> for the parent class just iterate over the parent table. After
>> examining the created table i see, that there is no discriminator
>> field (like in inheritance type SINGLE_TABLE), so OpenJPA has to
>> join all other tables just to find out about the type of the class
>> (=slow).
>>
>> Is it possible to add such a field to the parent table so OpenJPA
>> recognizes it and optimizes its queries? The OpenJPA documentation
>> does not describe such a behavior, but i think, it does not forbit it
>> either. Or should i ask this on the dev list?
>>
>> Thanks in advance,
>> Daniel Migowski
Re: Inheritance type JOINED
Posted by Marc Prud'hommeaux <mp...@apache.org>.
Daniel-
If you manually specify a @DiscriminatorColumn for the class ( http://
openjpa.apache.org/docs/latest/manual/
manual.html#jpa_overview_mapping_discrim ), does it help at all? I
suspect that we might just not have that optimization in place, but
it might be worth a shot.
On Jun 27, 2007, at 2:42 AM, Daniel Migowski wrote:
> Hello Users,
>
> I just tried out the inheritance type JOINED and added the subclass
> fetch mode NONE. My first thoughts were, that this would make
> queries for the parent class just iterate over the parent table.
> After examining the created table i see, that there is no
> discriminator field (like in inheritance type SINGLE_TABLE), so
> OpenJPA has to join all other tables just to find out about the
> type of the class (=slow).
>
> Is it possible to add such a field to the parent table so OpenJPA
> recognizes it and optimizes its queries? The OpenJPA documentation
> does not describe such a behavior, but i think, it does not forbit
> it either. Or should i ask this on the dev list?
>
> Thanks in advance,
> Daniel Migowski
>
>