Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] FW: [TopLink Essentials] @SqlResultSetMapping JOINed details are gettingignored

Hi
It looks like you may be facing the issue of a conditional outer join.
Please vote for:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=312146

This is related to getting this implemented in JPQL. JPQL does not
support the "ON" keyword in a join clause.

Regards,
Bernard

On Thu, 24 Jun 2010 14:49:58 +0200, you wrote:

>Today for the first time now I had to use @SqlResultSetMapping. While everything works well there so far, there still is one issue I would like to solve. Possibly you can help me. :-)
>
> 
>
>I am executing a typical master-detail JOIN:
>
> 
>
>SELECT Master.PK_A, Detail.PK_B FROM Master JOIN Detail ON (Master.PK_A = Detail.FK_A) WHERE Master.X = ? AND Detail.Y = ?
>
> 
>
>The result is exactly what I expected: A table containing all details having Y = ? and their corresponding masters.
>
> 
>
>But actually I want to get not fields but entity instances, so I added SqlResultSetMapping for Master and Detail, which both are annotated with @Entity, @Table, @Column, etc.
>
> 
>
>The result is not exactly what I want getÂ…: The "AND Detail.Y = ?" has no effect on that details linked with each master.
>
> 
>
>When iterating over the Master.details collection which was automatically filled by TopLink behind the scenes thanks to the @OneToMany relationship, I notice that ALL the master's details are contained - not just those with actually "Detail.Y = ?" as expected. Looking at the SQL TopLink does, it is rather clear why: The linked details are not filled from just my SQL's ResultSet, but actually TopLink executes another (automatically created) SQL to get ALL details per Master.
>
> 
>
>This is not what I want.
>
> 
>
>How to tell TopLink that it shall populate the linked details of each master with just the rows found in MY OWN SQL but not execute an unfiltered one?
>
> 
>
>Thanks!
>
>Markus



Back to the top