Why does my cfc method (when returning JSON format or called via remoting) return all related objects regardless of the lazy setting on the property?
Why does my cfc method (when returning JSON format or called via remoting) return
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
My guess is that when CF serializes those objects into JSON, it is forced to call the getters for the related objects, which in turn causes them to looked up in the database. The “lazy” property controls whether or not related objects are retrieved during the retrieval of the main objects or delayed until you actually request them. In this case, when serializing the object, the related objects are either looked up or not based on the JSON returned, so regardless of the lazy setting, they’ll come back.
Basically, if you have a data structure of baseball players and teams, if the JSON returned for a selected player (i.e. Josh Beckett) calls for info about the team (i.e. Red Sox), regardless of the lazy property setting, that team object will either be retrieved when you get the player object or when you ask for the team object that relates to the player.
Make sense?