0
域級別執行我有三個領域類的Grails的白水
class Caller implements Serializable{
String callingNumber
String callerName
static hasMany = [ callCallerList : CallCallerList ]
}
而其他都
class CallCallerList {
String reason
Caller caller
CallerList callerList
}
class CallerList {
String name
}
來電
和
CallerList
有一對多的關係與
CallCallerList
我在那裏我閱讀完所有的來電者,並把他們進入callCallerList巨大的csv文件。
def callerList = new CallerList(name:'test')
def callCallerLists = []
callerList.save(flush:true)
groovyFile.each {
ArrayList<String> line = it.split(',').toList()
def caller = new Caller(callingNumber:line.get(0),callerName:line.get(1))
//I want to save the object latter when I run the saveAll function for this domain class.
def callCallerList = new CallCallerList(caller:caller,callerList:callerList,reason:line.get(2))
callCallerLists.add(callCallerList)
// this gives me the error that caller is unsaved object.
}
CallCallerList.saveAll(callCallerLists)
我不希望保存來電,因爲我的進程得到緩慢的,如果數以百萬計的文件,如果記錄,同時創造大量callCallerList然後所有來電者保存,但不能以任何callerList出現一些錯誤。 我想這樣做
Caller.saveAll(callers)
CallCallerList(callCallerLists)