Quantcast

How to mark some non-association column as lazy?

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

How to mark some non-association column as lazy?

rosenfeld
Does GORM support marking a text column as lazy?

I'd like to use some HQL query like this:

select m from MyDomain m left join fetch m.associations

But there is an specific text column in the associated domain that I
don't need in my action and I'd like to exclude from the generated SQL
query, maybe by marking it as a lazy column.

Is that possible in GORM? I've heard Hibernate supports this, but I'm
not sure about GORM.

This column contains big data that will slow down the fetch.

Thanks in advance,
Rodrigo.

---------------------------------------------------------------------
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: How to mark some non-association column as lazy?

burtbeckwith
This isn't supported, but what you can do is create a second domain class that doesn't have that field in it, and map it to the same table. To reduce repetition, I'd put the common code in a src/groovy base class (to avoid Hibernate inheritance)

abstract class TheBaseClass {
        // common fields, constraints, etc.
}

and then extend it in two domain classes. The real one would just have the large field you're trying to avoid loading

class TheBigClass extends TheBaseClass {
   String theBigField
}

and the other would also extend the base class and have a mapping for the table name:

class TheClassWithoutTheBigField extends TheBaseClass {
   static mapping = {
      table 'the_big_class'
   }
}

Burt

On Thursday, March 15, 2012 04:56:40 PM Rodrigo Rosenfeld Rosas wrote:

> Does GORM support marking a text column as lazy?
>
> I'd like to use some HQL query like this:
>
> select m from MyDomain m left join fetch m.associations
>
> But there is an specific text column in the associated domain that I
> don't need in my action and I'd like to exclude from the generated SQL
> query, maybe by marking it as a lazy column.
>
> Is that possible in GORM? I've heard Hibernate supports this, but I'm
> not sure about GORM.
>
> This column contains big data that will slow down the fetch.
>
> Thanks in advance,
> Rodrigo.


---------------------------------------------------------------------
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: How to mark some non-association column as lazy?

rosenfeld
Thank you for the insight, Burt!

I'll evaluate if it worths for my case, thanks!

Best,
Rodrigo.

Em 16-03-2012 00:18, Burt Beckwith escreveu:

> This isn't supported, but what you can do is create a second domain class that doesn't have that field in it, and map it to the same table. To reduce repetition, I'd put the common code in a src/groovy base class (to avoid Hibernate inheritance)
>
> abstract class TheBaseClass {
> // common fields, constraints, etc.
> }
>
> and then extend it in two domain classes. The real one would just have the large field you're trying to avoid loading
>
> class TheBigClass extends TheBaseClass {
>     String theBigField
> }
>
> and the other would also extend the base class and have a mapping for the table name:
>
> class TheClassWithoutTheBigField extends TheBaseClass {
>     static mapping = {
>        table 'the_big_class'
>     }
> }
>
> Burt
>
> On Thursday, March 15, 2012 04:56:40 PM Rodrigo Rosenfeld Rosas wrote:
>> Does GORM support marking a text column as lazy?
>>
>> I'd like to use some HQL query like this:
>>
>> select m from MyDomain m left join fetch m.associations
>>
>> But there is an specific text column in the associated domain that I
>> don't need in my action and I'd like to exclude from the generated SQL
>> query, maybe by marking it as a lazy column.
>>
>> Is that possible in GORM? I've heard Hibernate supports this, but I'm
>> not sure about GORM.
>>
>> This column contains big data that will slow down the fetch.
>>
>> Thanks in advance,
>> Rodrigo.
>
> ---------------------------------------------------------------------
> 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: How to mark some non-association column as lazy?

Ime Asangansi
I've done this a few times.
Is this akin to some design pattern. Trying to do some writing around it.

Thanks for any tips.

Ime

Sent from my BlackBerry wireless device from MTN

-----Original Message-----
From: Rodrigo Rosenfeld Rosas <[hidden email]>
Date: Mon, 19 Mar 2012 10:27:09
To: <[hidden email]>
Reply-to: [hidden email]
Subject: Re: [grails-user] How to mark some non-association column as lazy?
Thank you for the insight, Burt!

I'll evaluate if it worths for my case, thanks!

Best,
Rodrigo.

Em 16-03-2012 00:18, Burt Beckwith escreveu:

> This isn't supported, but what you can do is create a second domain class that doesn't have that field in it, and map it to the same table. To reduce repetition, I'd put the common code in a src/groovy base class (to avoid Hibernate inheritance)
>
> abstract class TheBaseClass {
> // common fields, constraints, etc.
> }
>
> and then extend it in two domain classes. The real one would just have the large field you're trying to avoid loading
>
> class TheBigClass extends TheBaseClass {
>     String theBigField
> }
>
> and the other would also extend the base class and have a mapping for the table name:
>
> class TheClassWithoutTheBigField extends TheBaseClass {
>     static mapping = {
>        table 'the_big_class'
>     }
> }
>
> Burt
>
> On Thursday, March 15, 2012 04:56:40 PM Rodrigo Rosenfeld Rosas wrote:
>> Does GORM support marking a text column as lazy?
>>
>> I'd like to use some HQL query like this:
>>
>> select m from MyDomain m left join fetch m.associations
>>
>> But there is an specific text column in the associated domain that I
>> don't need in my action and I'd like to exclude from the generated SQL
>> query, maybe by marking it as a lazy column.
>>
>> Is that possible in GORM? I've heard Hibernate supports this, but I'm
>> not sure about GORM.
>>
>> This column contains big data that will slow down the fetch.
>>
>> Thanks in advance,
>> Rodrigo.
>
> ---------------------------------------------------------------------
> 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: How to mark some non-association column as lazy?

jphiloon
Could someone comment on the caching implications when two domain classes point to the same table?  My understanding is that they are unrelated in terms of caching, and an update to a field in one class would not be evident in the other.  True?  Is there a way to invalidate the "other" class cache?
Loading...