Quantcast

Eager loading only some columns

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Eager loading only some columns

larini
Hi, I had two models: Book and Author

I need to select the book, and brings some columns from the author association. When I did
Book.findAllByPublisher(publisherx, [fetch:[author:'eager']])

it brings all columns from the author table.

How can I bring only the columns that I need (lets say, id and name) ?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Eager loading only some columns

Ilya Sterin
I don't think you can, you'll probably just have to either create a
model class representing only those two values or create your own
repository method that builds the object graph with a custom query.

Ilya

On Wed, Sep 9, 2009 at 10:27 PM, larini <[hidden email]> wrote:

>
> Hi, I had two models: Book and Author
>
> I need to select the book, and brings some columns from the author
> association. When I did
> Book.findAllByPublisher(publisherx, [fetch:[author:'eager']])
>
> it brings all columns from the author table.
>
> How can I bring only the columns that I need (lets say, id and name) ?
> --
> View this message in context: http://www.nabble.com/Eager-loading-only-some-columns-tp25376177p25376177.html
> Sent from the grails - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Eager loading only some columns

Ilya Sterin
Also, I don't think this is good OO practice anyways.  You have an
object that doesn't have consistent invariants applied to it which
would be pretty confusing.

Ilya

On Thu, Sep 10, 2009 at 11:34 AM, Ilya Sterin <[hidden email]> wrote:

> I don't think you can, you'll probably just have to either create a
> model class representing only those two values or create your own
> repository method that builds the object graph with a custom query.
>
> Ilya
>
> On Wed, Sep 9, 2009 at 10:27 PM, larini <[hidden email]> wrote:
>>
>> Hi, I had two models: Book and Author
>>
>> I need to select the book, and brings some columns from the author
>> association. When I did
>> Book.findAllByPublisher(publisherx, [fetch:[author:'eager']])
>>
>> it brings all columns from the author table.
>>
>> How can I bring only the columns that I need (lets say, id and name) ?
>> --
>> View this message in context: http://www.nabble.com/Eager-loading-only-some-columns-tp25376177p25376177.html
>> Sent from the grails - user mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Eager loading only some columns

larini
In reply to this post by larini

Any clue ?
--
View this message in context: http://www.nabble.com/Eager-loading-only-some-columns-tp25376177p25385643.html
Sent from the grails - user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Eager loading only some columns

larini
In reply to this post by Ilya Sterin
In my case, I am sending this objects to flex via BlazeDs, so if I can cut something will be very good.
Loading...