我有以下2个域类
class Foo implements Serializable {
Long fooId1
Long fooId2
Long hFooId1
Long hFooId2
Foo hFoo
Bar bar
static mapping = {
datasources(['ds1','ds2'])
id composite: ["fooId1", "fooId2"]
version false
columns {
bar(insertable: false, updateable: false) {
column name: 'fooId1'
column name: 'fooId2'
}
hFoo(insertable: false, updateable: false) {
column name: 'hFooId1'
column name: 'hFooId2'
}
}
}
static constraints = {
hFooId1 nullable: true
hFooId2 nullable: true
bar nullable: true
hFoo nullable: true
}
}
class Bar implements Serializable
{
Long fooId1
Long fooId2
Foo foo
static mapping = {
datasources(['ds1','ds2'])
id composite: ["fooId1", "fooId2"]
version false
cache include: 'non-lazy'
foo(insertable: false, updateable: false) {
column name: 'fooId1'
column name: 'fooId2'
}
}
}
通过集成测试......
@Integration
@Rollback
@Mock([Foo, Bar])
....
def "Simple Test"(){
expect:
def bar = Bar.build( fooId1: 1, fooId2: 2)
def hFoo = Foo.build( fooId1: 1, fooId2: 2, bar: bar)
def foo = Foo.build( fooId1: 123, fooId2: 456, hFoo: hFoo)
foo.fooId2 == 456
foo.hFoo.fooId2 == 2
foo.bar == null
foo.hFoo.bar.fooId2 == 2
}
我得到了
无法将org.grails.orm上的org.grails.orm.hibernate.cfg.PropertyConfig.checkHasSingleColumn(PropertyConfig.groovy:222)中的多列属性视为单列属性,org.grails.orm.hibernate.cfg.PropertyConfig.getScale (PropertyConfig.groovy:198)
这是升级,所以它似乎在Grails 2中起作用 -
有人能看到我错过的东西吗?
答案 0 :(得分:1)
看起来这是一个版本问题......
这适用于build.gradle
// compile "org.grails.plugins:hibernate4"
或者在gradle.properties中...
grailsVersion=3.0.11