Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Exclude fields from Select

join-fetch is only relevant to object queries.  Since you are only querying
data, there is no point to the hint, just remove it.

If you need a outer join for the related objects you can use,

FROM A a left join a.cs c left join a.ds d

In general it may be better just to always select the objects back, even if
you may not use a couple of the fields.  You could also investigate using
fetch groups.


Joe Mc. wrote:
> 
> ...so one step further:
> 
> with Collection/relation traversal the SELECT-Statement could be:
> SELECT
>    a.b.id,
>    a.b.name,
> 
>    c.id,
>    c.no, ...
> 
>    d.id,
>    d.label, ...
> FROM A a, IN(a.cs) c, IN(a.ds) d
> 
> But I have here now a new problem! I use query hint
> eclipselink.left-join-fetch to retrieve the related data.
> This query hint is not valid for the resulting SELECT-Statement! Maybe
> only queries allowed which have a single object in their SELECT clause?
> 
> 
> So, does anyone know a (better) solution?
> 
> Thanks
> 
> Joe
> 
> 
> 
> 
> Joe Mc. wrote:
>> 
>> Hi folks,
>> 
>> I have some question about excluding some fields from a SELECT-Statement.
>> I would in some SELECT-Statements include the denoted fields, and in some
>> statements not.
>> My problem is maybe the class hierarchy. Following example:
>> 
>> A    ->    B (embeds Bextra)    
>>       ->*  C -> CE
>>       ->*  D
>> 
>> Class A keeps some references to the classes B, C and D. Further keeps
>> class C a reference to CE.
>> Class A keeps a list of C and D objects.
>> Class B embeds Bextra. 
>> 
>> So, I will fire some SELECT-Statements with the fields in the @Embeddable
>> class Bextra and some statements without this embeddable class.
>> 
>> Is it possible?
>> 
>> If I use 
>> SELECT a FROM A a
>> I get all the fields - understandable.
>> So I tried to define in the SELECT-Statements all the fields I want,
>> without the fields from the Bextra class. And here I get the problem to
>> define it...
>> 
>> SELECT 
>>  // only the fields from B, without Bextra: e.g.:  a.b.bextra.city
>>  a.b.id,               
>>  a.b.name,
>>  // now the other fields for the C and D class
>>  a.cs.id          //=> Not possible: cannot navigate collection valued
>> association field
>>  // the same is for the collection of D objects
>>  ...
>> FROM A a
>> 
>> So, my question is:
>> 1. How to exclude special fields (all in a embeddable class) in some
>> SELECT-Statements
>> OR
>> 2. How to define the Query with all the wanted fields in the case with
>> collection fields
>> 
>> AND
>> I want only one query :-)
>> 
>> Is it possible?
>> 
>> I hope you can understand the basic concept of this scenario, otherwise
>> do not hesitate to ask!
>> Thanks in advance for any hints!
>> 
>> Regards
>> 
>> Mc.Joe
>> 
>> Key data:
>> - Eclipselink 1.1.1
>> - MS SQL 
>> 
>> 
> 
> 


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://old.nabble.com/Exclude-fields-from-Select-tp26617240p26695059.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top