1
我有以下2個域類似乎無法複合的ID Grails的結合3
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.hibernate.cfg.PropertyConfig.checkHasSingleColumn(PropertyConfig.groovy:222)上的單列屬性在org.grails.orm.hibern ate.cfg.PropertyConfig.getScale(PropertyConfig.groovy:198)
這是升級所以它出現在Grails的已工作2 -
有人能看到我缺少的是什麼?