How to access Grails domain classes in Java service layer?

后端 未结 3 1331
难免孤独
难免孤独 2021-01-07 00:46

How can I use grails domain classes (which is in groovy) in service layer which is in Java/Spring.

When using the grails MVC, everything is fine as I can use contro

3条回答
  •  心在旅途
    2021-01-07 01:03

    Sample Code Snippet :

    import my.package.User
    import org.codehaus.groovy.runtime.InvokerHelper;
    
    
    List allInstances = (List)InvokerHelper.invokeMethod(User.class, "list", null)); 
    
    
    User one=(User)InvokerHelper.invokeMethod(User.class, "get", id); 
    

提交回复
热议问题