Reputation: 1464
Is there any way to use Grails findAll to a toString from a Complex Object?
I have an Object named Person (example).
Person has firstName and lastName attributes and there is a toString method that returns "FirstName: " + firstName + "LastName: " + lastName
And there is another object that have Person named Group. Group has an attribute of Person.
I want to search like:
Group.findAll{
ilike("person.toString", "%FirstName%")
}
I'm getting the following:
could not resolve property: person.toString of: com.test.Group. Stacktrace follows:
Message: could not resolve property: person.toString of: com.test.Group
Line | Method
->> 670 | doCall in grails.gorm.DetachedCriteria$_list_closure2
Is there a way to use findAll comparing to a toString method? I can't create a getFirstAndLastName because the object is a plugin to another project and can't be modified.
Upvotes: 0
Views: 167
Reputation: 27200
Is there a way to use findAll comparing to a toString method?
No. The only way to invoke toString
, or any other method, on entities would be to retrieve them, bring them into the app so the instances can be created and then invoke the methods. If the toString
happens to return something that you can simulate without actually invoking the method then you might have options but the answer to the question as asked is "no".
I hope that helps.
Upvotes: 1