grails - Can I call GORM "find" methods on an object instead of the class? -
I am trying to take advantage of the fact that groovy is more dynamic than Java. I have to be a block of code which
TypeA type = // do something to create an object TypeA dbType = TypeA.findBySomethingAnd something (some, some) if (dbType! = Null ) Type.id = dbType.id type.save () But it can work for many objects that support the same findBySomethingAndSomething method.
Is it possible to say
def type = // Type something to type an object def db =. FDIBijings and some (type identifier, type. Authorization) if (dbipap! = Null) type. Id = dbip.id type.save () "Better" way? I am trying to avoid a large switch statement or if / other series which essentially does the same thing for each type.
You can always class object with an example of example.getClass () Can get through. Therefore, the following should work:
example.getClass (). FindBySomethingAndSomething (type.identifier, type.otheridentifier) findBySomethingAndSomething
Comments
Post a Comment