0
votes

I followed the documentation and put my JPA annotated classes under src/main/java.

In addition I put a hibernate.cfg.xml under conf/hibernate which looks like this:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD//EN"
        "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <mapping package="com.damluar" />
        <mapping class="com.damluar.CustomerPropertyEntity"/>
        ...
    </session-factory>
</hibernate-configuration>

I also found mentions that I need to add

configClass = org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsAnnotationConfiguration

to my DataSource.groovy.

Then I generated controllers and views using scaffolding. When I start the app or use a console, Grails throws exception:

URI
    /dataTypeEntity/index
Class
    groovy.lang.MissingMethodException
Message
    No signature of method: static com.damluar.DataTypeEntity.count() is applicable for argument types: () values: [] Possible solutions: print(java.lang.Object), print(java.io.PrintWriter), wait(), dump(), collect(), find()

It looks like Grails doesn't add persistence methods to the domain classes.

Also when I start the application Grails lists existing artefacts: Artefacts

Controllers: 3
Domains: 0
1

1 Answers

0
votes

I had a similar issue with Grails 3.0.1, and the solution was to put hibernate.cfg.xml in grails-app/conf (not inside a hibernate subdirectory) as described in mapping-with-hibernate-annotations-in-grails-3-0-1.