我试图在两个域之间映射一对一的关系,其中TemplateOutputTransDisplayMap具有来自TemplateOutput的外部PK。当我去保存ToTransDisplayMap的实例时,我收到以下错误:
org.hibernate.id.IdentifierGenerationException 尝试从null一对一属性中分配id [TemplateOutputTransDisplayMap.templateOutput]
两个域的代码都在下面,从TemplateOutputTransDisplayMap开始,然后是TemplateOutput:
class TemplateOutputTransDisplayMap {
static belongsTo = [templateOutput:TemplateOutput, templateStep:TemplateStep]
TemplateOutput templateOutput
Long id
String tsStep
String toParameterName
String displayLabel
String defaultValue
String toMapParameter
String sqlQuery
String selectClause
String whereClause
Long fetchCount
String transTable
String columnName
String displayed
String xPath
String isNameValue
static mapping = {
table 'TO_TRANS_DISP_MAP'
version false
id column: 'TO_SYSID', generator: 'foreign', params: [property:'templateOutput']
templateOutput column: 'TO_SYSID', insertable: false, updateable: false
templateStep column: 'TO_TS_SYSID'
tsStep column: 'TS_STEP'
toParameterName column: 'TO_PARAM_NAME'
displayLabel column: 'DISPLAY_LABEL'
defaultValue column: 'DEFAULT_VALUE'
toMapParameter column: 'TO_MAP_PARAM'
sqlQuery column: 'SQL_QUERY'
selectClause column: 'SELECT_CLAUSE'
whereClause column: 'WHERE_CLAUSE'
fetchCount column: 'FETCH_COUNT'
transTable column: 'TRANS_TABLE'
columnName column: 'COLUMN_NAME'
xPath column: 'XPATH'
isNameValue column: 'IS_NAME_VALUE'
}
static constraints = {
tsStep (maxSize:250, blank:true, nullable:true)
toParameterName (maxSize:250, blank:true, nullable:true)
displayLabel (maxSize:250, blank:true, nullable:true)
defaultValue (maxSize:250, blank:true, nullable:true)
toMapParameter (maxSize:250, blank:true, nullable:true)
sqlQuery (maxSize:1000, blank:true, nullable:true)
selectClause (maxSize:100, blank:true, nullable:true)
whereClause (maxSize:1000, blank:true, nullable:true)
fetchCount (maxSize:3, blank:true, nullable:true)
transTable (maxSize:250, blank:true, nullable:true)
columnName (maxSize:30, blank:true, nullable:true)
displayed (maxSize:1, blank:true, nullable:true)
xPath (maxSize:2000, blank:true, nullable:true)
isNameValue (maxSize:3, blank:true, nullable:true)
templateStep (blank:true, nullable:true)
}
}
class TemplateOutput {
static belongsTo = [templateStep:TemplateStep]
static hasOne = [templateOutputTransDisplayMap:TemplateOutputTransDisplayMap]
Long id
String parameterName
String usage
String mappingParameter
static mapping = {
table 'TEMPLATE_OUTPUT'
version false
id column: 'SYSID', generator: 'assigned'
templateStep column: 'TS_SYSID'
parameterName column: 'PARAMETER_NAME'
mappingParameter column: 'MAPPING_PARAMETER'
}
static constraints = {
parameterName (maxSize:250, blank:true, nullable:true)
usage (maxSize:250, blank:true, nullable:true)
mappingParameter (maxSize:250, blank:true, nullable:true)
templateStep (blank:true, nullable:true)
templateOutputTransDisplayMap (blank:true, nullable:true)
}
}
任何帮助都将不胜感激。