Stuart-campbell / RushOrm

Object-relational mapping for Android
http://www.rushorm.co.uk/
Other
172 stars 19 forks source link

Querying using objects getters and setters #122

Open danielkmb2 opened 8 years ago

danielkmb2 commented 8 years ago

Hello,

I want to retrieve the parent of an object given one of child fields. Is there any way to archieve this?

ex. Dog has name, human has name and list of dogs. Given a dog`s name i want to know its humans name.

Thanks!

Stuart-campbell commented 8 years ago

Hi,

I think this would have to be done in two searches.

Dog dog = new RushSearch().whereEqual("name", dogName).findSingle(Dog.class);
Parent parent = new RushSearch().whereEqual("listField", dog).findSingle();

It's unlikely you would want to use findSingle i'm sure you would want to use find and check there are actually results.

Hope that helps.

Thanks