If you subCategories collections are relatively small, then you should
be safe to just loop over it and terminate after the third row.  Yeah,
you'll be getting more than you need back from the database, but
Hibernate is really good about optimizing data access for
relationships, so I'd assume it WON'T be a problem until you
demonstrate via load testing that it is.

No question, ORM is quite a departure from the normal SQL world.  It
can be hard to get into, but it's worth giving it a try.  Really.  The
payoffs in the maintenance phase are huge, because you're expression
your code at a much higher level than with SQL.

cheers,
barneyb

On Sun, Jan 17, 2010 at 10:44 AM, Victor Moore <victor.mo...@gmail.com> wrote:
>
> Hi Barney,
>
> After trying to find the answer to the question for almost a day I was
> afraid that the answer is no but just wanted to be sure :)
> The reason I want only a few is for display purposes. Just to give
> some indication to users the type of subcategories exists.
>
> While I like the idea of ORM, I'm afraid to use it in a heavy
> production environment because I don't really know the guts of it and
> may introduce problems that are hard to debug.
> I'm starting a new project and I'm on the fence. I'm just learning it
> and don't want to jeopardize it because my inexperience (with ORM)
> plus (at least initially) will take me more time to code than using
> direct SQL, I know SQL, it comes very easy to work with and (for the
> most part) I understand, can optimize and test it.
>
> Thanks
>
> Victor
>
> On Sat, Jan 16, 2010 at 11:58 PM, Barney Boisvert <bboisv...@gmail.com> wrote:
>>
>> The short answer is "no".
>>
>> The long answer is that yeah, you can do a whole bunch of hacking
>> around to make it work like that (or at least APPEAR to work like
>> that), but it's a mess.  I can't think of a case when you wouldn't be
>> better off a) just constraining the loop over the subcategories when
>> you go to use them, or b) using a separate query for subcategoies
>> rather than a relationship traversal.
>>
>> What's your reason for wanting to only get three?
>>
>> cheers,
>> barneyb
>>
>> On Sat, Jan 16, 2010 at 8:49 PM, Victor Moore <victor.mo...@gmail.com> wrote:
>>>
>>> Hi,
>>>
>>> I have the following cfc:
>>> component output="false" persistent="true" entityname="Category"
>>> table="category"
>>> {
>>>        property name="catID" column="cat_id";
>>>        property name="name" ;
>>>        property name="subCategories"
>>>                        fieldtype="one-to-many" cfc="SubCategory" 
>>> singularname="SubCategory"
>>>                        fkcolumn="cat_id" cascade="all" lazy="extra";
>>>
>>> }
>>>
>>> is it possible to retrieve only 3 subCategories when calling
>>> entityLoad ("Category")?
>>>
>>> Thanks
>>> Victor
>>>
>>>
>>
>>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:329743
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to