BootStrap.groovy 加载开发数据时出现问题。之前它总是加载数据,但现在在运行 grails run-app 时停止抛出以下错误。
Message: Validation Error(s) occurred during save():
- Field error in object 'spotlight.content.Profile' on field 'portfolio': rejected value [null];
我的2个模型如下;
class Portfolio {
Profile profile
String portfolioName
String portdescrip
Integer portpublished
Date dateCreated
Date lastUpdated
和
class Profile {
static belongsTo = [portfolio: Portfolio]
String portfoliohtml
String portfolioEmail
String portfoliocc
String portfolioAdmin
String portfolioFilestore
String portfolioColor
String bugzillaproduct
String bugzillacomponent
String rtqueue
String teamqueueemail
String etherpadurl
Integer siteupload
Date dateCreated
Date lastUpdated
在 BootStrap.groovy 文件中,我有以下内容;
import java.util.Date;
import spotlight.content.Profile
import spotlight.content.Portfolio
class BootStrap {
def init = { servletContext ->
def profile = new Profile(portfoliohtml:"No",
portfolioEmail: "ian@ian.com",
portfolioAdmin:"Ian Neilsen",
bugzillaproduct:"bz prod name",
bugzillacomponent:"comp name",
siteupload:1,
portfoliocc: "ian@ian.com",
portfolioColor:"red",
portfolioFilestore:"blah",
rtqueue:"queue name",
teamqueueemail:"ian@ian.com",
etherpadurl:"http://url.com",
).save(failOnError: true)
def portfolio = new Portfolio(portfolioName:"Portfolio 1",
portdescrip:"portfolio descrition field",
portpublished:1,
portfolio:profile).save(failOnError: true)
}
我已经尝试了将我的个人资料对象添加到投资组合对象的所有化身,但没有任何运气。正如我之前所说,这有效,现在已经停止抛出空错误。
让我有什么想法吗?
干杯