GORM fails to realize Domain classes from a plugin are GORM classes

大憨熊 提交于 2019-12-01 07:39:00

The issue with the domain not being recognized as a GORM class was due to the constructors provided in them. These constructors were generated from s2-quickstart, but should be removed (it's a bug in spring-security-core). I removed the constructors and the one place you were using them I used map style default constructors. Then I fixed the call you had to get the current user.

The repaired source is in this repo on GitHub (patch-1 branch is working, master is the OP's original broken code)

I received the same error message when running a plugin containing GORM domains using grails run-app in Grails 3.1.6. I fixed the problem by providing explicit configuration for initialising Hibernate as follows:

build.gradle:

dependencies {
    ...
    runtime "org.grails.plugins:hibernate4"
    runtime "org.hibernate:hibernate-ehcache"
}

grails-app/conf/application.yml:

---
environments:
    development:
        hibernate:
            cache:
                queries: false
                use_second_level_cache: true
                use_query_cache: false
                region.factory_class: 'org.hibernate.cache.ehcache.EhCacheRegionFactory'

         dataSource:
             pooled: true
             jmxExport: true
             driverClassName: org.h2.Driver
             username: sa
             password:
             dbCreate: create-drop
             url: jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!