micromax / activejdbc

Automatically exported from code.google.com/p/activejdbc
0 stars 0 forks source link

Content Features Functionality #199

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Possible feature request.

I was just curious if there was a reason that the include() method couldn't be 
added to the Model class so that associations of a single instance of a Model 
couldn't be fetched.  Right now one needs to fetch a collection of Models to 
populate with children  

Unless I'm mistaken, to accomplish the same thing, I currently have to do 
something like this

class Plan extends Model {
     public Plan getPopulatedPlan() {
        return (Plan) (this.where("id = ?", getId()).include(Member.class)).get(0);
    }
}

So what would be nice is a 
Model.include(Class klass)
Model.includeAll(ArrayList<Model?> childClassesToInclude)

As I'm doing this so that I can fully populate a JSON / Xml object graphs, 
With the above, one could create useful variations of toJson which included 
child vectors.

I'm Currently using 1.4.8

Thanks!
Peter

Original issue reported on code.google.com by pabramow...@gmail.com on 13 Dec 2013 at 6:39