|
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) ? |
|
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 |
|
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 |
|
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 |
| Powered by Nabble | Edit this page |
