4

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. Commented Aug 17, 2011 at 20:29

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I played with the Id field a little and I found a workaround without renaming. Thanks.
What about using traits ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.