4
votes

I have four components in my large project that I'm working on...

  1. Existing JPA/Hibernate java library (java domain).
  2. Existing service layer that works with the java domain.
  3. Java class library of only basic interfaces (api and meta-data).
  4. New grails project

I have successfully tied most of this together except one last piece. I have an existing servlet that takes in a interface class from the api but I can't seem to implement my interface on any of the grails domain classes.

An example...

Interface example in the api library...

public interface IPerson{
    public Object getId()
    public String getName()
}

Grails domain class...

class Person implements IPerson{
...
    def getId(){
        return id
    }

    String getName(){
       return name;
    }

}

My project works fine without the interface on the grails domain class but as soon as I add it, it seems to not be identified as an entity. I get errors like

groovy.lang.MissingMethodException: No signature of method: static com.some.thing.Person.getAll() is applicable for argument types: () values: []

Has anyone ever tried something like this?

1
Do you have also setters (even with empty body) for id and name in Person? I don't know if they are omitted in listing or not.Artur Nowak

1 Answers

5
votes

Problem is apparently caused by the fact that one of the methods is called getId(), so it's essentially defining domain class field id, which clashes with the implicit one. So you can solve the problem by renaming this method or (hopefully, haven't tested myself) changing generation strategy as described here.