Grails3域类组合

Grails3域类组合,grails,dns,composition,Grails,Dns,Composition,使用Grails3.2.5,Hibernate5.1.2内核 我有一个遗留数据库,在一个表中有几个CLOB。为了避免急取,在Grails的早期版本中,我定义了一个只包含这些CLOB的域类,以便通过一个明显的关联来访问它们,然后可以延迟地获取这些CLOB。设置的草图: class Comment { String someField // eager CommentText cmntText // lazy static mapping = {

使用Grails3.2.5,Hibernate5.1.2内核

我有一个遗留数据库,在一个表中有几个CLOB。为了避免急取,在Grails的早期版本中,我定义了一个只包含这些CLOB的域类,以便通过一个明显的关联来访问它们,然后可以延迟地获取这些CLOB。设置的草图:

class Comment {
    String someField        // eager
    CommentText cmntText    // lazy

    static mapping = {
      id column: 'COMMENT_ID', generator:'sequence', params:[sequence:'cmnt_seq']
}

In a separate domain class file:

class CommentText {
   String userComment
   static mapping = {
     table 'COMMENT'
     id generator:'assigned'
     userComment sqlType:'clob'
}

As noted, clob column 'user_comment' exists in the single table 'COMMENT'.
在3.2.5中,执行此操作时,我得到一个错误,即“comment”表中未定义“comment\u text\u id”列。过去情况并非如此,字段也不应该存在

类似地,在另一种情况下,我定义了一个复合域类,一个与实际域类在同一文件中定义的类。在这种情况下,我也会得到一个关于缺少id的错误:

class A {
    B b
}

class B {
   String someField
}
在这种情况下,我得到一个错误,表示字段b_id不在表“A”中。但是-它应该是嵌入的组成,它不应该在那里


如果相关的话,我将在Intellij中构建。

使用GORM 6.1,现在只需一个域类就可以了

import grails.gorm.hibernate.annotation.ManagedEntity
import static grails.gorm.hibernate.mapping.MappingBuilder.*

@ManagedEntity
class Comment {

    String someField
    String userComment

    static constraints = {
    }

    static final mapping = orm {
        id {
            generator("sequence")
            params(sequence:'cmnt_seq')
        }
        userComment = property {
            lazy(true)
            column {
                sqlType 'clob'
            }
        }
    }

}

我试图通过更改build.gradle来更新我的项目。但是,它找不到ManagedEntity导入,并且认为Comment不是域类。我不确定Grails3.2.5或3.2.8是否强制使用Gorm版本,这是我的问题,还是其他问题。我假设我不必使用dsl版本的映射,但是如果我恢复到旧样式,我可以编译,但是userComment不是惰性加载的。哦,my build.gradle:compile org.grails.plugins:hibernate5:6.0.11//JTP compile org.hibernate:hibernate ehcache