Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6038149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:10:35+00:00 2026-05-23T06:10:35+00:00

Once you have loaded a component are you then able to access properties of

  • 0

Once you have loaded a component are you then able to access properties of that object with set conditions? For instance, if you have a one-to-many relationship between people and pets, you load people specifying a particular person, you then want to pull all said persons pets where the pets are of a particular species. cats vs dogs for instance.

<cfset person=EntityLoad("person", {name="#URL.name#"})>
<cfset pets=person[1].getPets()>

is there anyway to call getPets where type=’dog’ or something?

Or would I have to loop through the pets creating structures for each type and deal with them that way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T06:10:36+00:00Added an answer on May 23, 2026 at 6:10 am

    You should not loop through the pets if at all possible: distinguishing between types of pets is best left to the object that has a relationship with them or to a service that works with those objects.

    One approach is to add a method to Person that will return a type of Pet. We’re using something similar in our current project.

    array function getDogs() {
        var HQL = "where petType = 'dog'";
        return ormGetSession().createFilter(this.getPets(),HQL).list();
    }
    

    You might also be able to make it more generic:

    array function getPets( required string petType ) {
        var HQL = "where petType = '" & arguments.petType & "'";
        return ormGetSession().createFilter(this.getPets(),HQL).list();
    }
    

    Another approach is to use the where attribute in relationships in the Person object when retrieving pets. We use something like this as well:

    property name="cats" type="array" fieldtype="one-to-many" cfc="model.Pets" fkcolumn="PERSON_ID" where="PET_TYPE = 'cat'" lazy="false";
    property name="dogs" type="array" fieldtype="one-to-many" cfc="model.Pets" fkcolumn="PERSON_ID" where="PET_TYPE = 'dog'" lazy="false";
    

    Note that these examples make several assumptions about the structure of your app and database: there is a Pets object in the model folder that maps to a table in your db; this table has a PET_TYPE column (that maps to a petType property) that contains pet types in lower case; the Person object maps to a table with a primary key called PERSON_ID, which is also a foreign key in the Pets table.

    Also, when considering these and other approaches, you should think about how you intend to access pets. Turning off lazy loading can create performance hits if you have a significant number of Pets, particularly if there are several types you want to store (so you’re making several passes through the Pets table when initializing a Person). You may not need separate properties if you don’t access Pets often; it may be enough simply to have a getPets() function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to have images fade in with css3 once they're loaded. The problem
Once you have your first set of requirements and design done where do you
I have an xml file that will be read many times from the source
Once i have loaded my model and filtered it if i need to, how
I have a main tabController that has two tabs, first one is selected as
I have a web app that is heavily loaded in javascript and css. First
I have a page with a list of items initially loaded from a include_once('show_calendarV2.php');
I once have noticied when my Adobe Reader was updating, I saw a small
Once you have uploaded your source code to Heroku, is it possible to download
Once I have programmed GUI with Java and have used Form Layouts. Form layout

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.