Are derived properties lazy loaded?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Are derived properties lazy loaded?

jondo_w
I've looked at: http://www.grails.org/doc/latest/guide/5.%20Object%20Relational%20Mapping%20%28GORM%29.html#5.5.2.11%20Derived%20Properties

It doesn't indicate whether derived properties are lazy loaded. I have a GORM class that I could add derived properties to, but in the places where I might want to do a:

select p from Profile p where p.account = ?

I don't want to run those derived property queries for all Profile's for that HQL query above. I can of course just individually indicate the fields I need, or can I?

Can anybody elaborate on the above? I also read the Hibernate docs for derived properties but they also gave no explicit clues.

Thanks,
Darryl Pentz
Reply | Threaded
Open this post in threaded view
|

Re: Are derived properties lazy loaded?

John Fletcher-3
I think they are not lazy-loaded.
 
I take it that "account" is not the derived property in your example. I don't have any more insight into the answer than you, but look at this quote from the documentation:
 
"With that in place, when a Product is retrieved with something like Product.get(42), the SQL that is generated to support that will look something like this:
select
    product0_.id as id1_0_,
    product0_.version as version1_0_,
    product0_.price as price1_0_,
    product0_.tax_rate as tax4_1_0_,
    product0_.PRICE * product0_.TAX_RATE as formula1_0_
from
    product product0_
where
    product0_.id=?"
Does this not clearly indicate that derived properties are keenly-loaded (or whatever the term is)?
 
If that is not sure enough for you, there is a logSql config option which you could switch on and check what is being generated.
 
Regards,
John

 
2011/7/14 Darryl Pentz <[hidden email]>

It doesn't indicate whether derived properties are lazy loaded. I have a GORM class that I could add derived properties to, but in the places where I might want to do a:

select p from Profile p where p.account = ?

I don't want to run those derived property queries for all Profile's for that HQL query above. I can of course just individually indicate the fields I need, or can I?

Can anybody elaborate on the above? I also read the Hibernate docs for derived properties but they also gave no explicit clues.

Thanks,
Darryl Pentz