【发布时间】:2013-12-05 09:39:23
【问题描述】:
我有两个域类,有很多映射。
一节课:
class Line {
static belongsTo = [header : Header]
Long invoiceId
Long lineNumber
Long oneId
Long secondId
Long thirdId
static mapping = {
table('LINES_2_V')
version(false)
id composite: ['invoiceId', 'lineNumber']
}
}
另一个类:
class Header {
static hasMany = [lines: Line]
Long id
static mapping = {
table('HEADERS_2_V')
version(false)
id column:'INVOICE_ID'
}
}
创建:
Header.createCriteria().list() {
createAlias('Lines', 'l', CriteriaSpecification.INNER_JOIN)
if (oneId) {
eq('l.oneId', oneId)
} else {
isNull('l.oneId')
}
if (secondId) {
eq('l.secondId', secondId)
}else {
isNull('l.secondId')
}
if (thirdId) {
eq('l.thirdId', thirdId)
}else {
isNull('l.thirdId')
}
}
我得到以下错误:
ORA-00904: "L1_"."HEADER_ID": invalid identifier
Hibernate 生成的选择如下所示:
Hibernate: select * from ( select this_.INVOICE_ID as INVOICE1_0_1_
from HEADERS_2_V this_,
LINES_2_V ihl1_ where this_.INVOICE_ID=l1_.header_id and ihl1_.project_id is null
and ihl1_.transaction_id is null and ihl1_.po_header_id is null ) where rownum <= ?
为什么它试图通过 HEADER_ID 映射?如何使其通过INVOICE_ID 映射?
【问题讨论】:
标签: grails mapping grails-orm many-to-one