Note that there are some explanatory texts on larger screens.

plurals
  1. POGrails dynamic finder methods on domain classes not visible across plugin projects
    primarykey
    data
    text
    <p>My development environment is as follows:</p> <p>Grails version: 1.3.7.RELEASE</p> <p>Follow the steps below:</p> <ol> <li><code>mkdir GrailsProjects</code></li> <li><code>cd GrailsProjects</code></li> <li><code>grails create-plugin grails-domain</code></li> <li><code>cd grails-domain</code></li> <li><code>grails create-domain-class Book</code></li> <li><code>cd ..</code></li> <li><code>grails create-plugin grails-service</code></li> <li><code>cd grails-service</code></li> <li><code>grails create-service BookService</code></li> <li><p>Add</p> <blockquote> <pre><code>grails.plugin.location."grails-domain" = "../grails-domain" </code></pre> </blockquote> <p>at the top of the file <code>BuildConfig.groovy</code> in the <code>grails-service</code> project</p></li> <li><p>Using a text editor, change the content of the file <code>Book.groovy</code> to:</p> <blockquote> <pre><code>package grails.domain class Book { String name static constraints = { } } </code></pre> </blockquote></li> <li><p>Change the content of the file <code>BookService.groovy</code> to:</p> <blockquote> <pre><code>package grails.service import grails.domain.Book class BookService { static transactional = true def someMethod() { def book = Book.findByName("Fooled by randomness") } } </code></pre> </blockquote></li> </ol> <p>On trying to call the method <code>BookService.someMethod</code>, Grails is unable to find the <code>findByName</code> method on <code>Book</code>. <code>Book.name</code> is visible inside <code>BookService.someMethod</code>, which indicates that the <code>grails-service</code> plugin project is able to resolve the code in the <code>grails-domain</code> plugin project.</p> <p>The steps are exactly as listed above; no additional steps have been performed.</p> <p>Is this expected behaviour with Grails plugin projects? Is there a different way to separate domain and service classes with Grails?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload