我这里有一个代码,它会循环一次表。但是,如果没有数据要传递给数据库,我想停止循环。有没有办法阻止循环?代码如下:
if(abcJob.save(flush: true)){
def xyzTracking
XYZTracking.withTransaction{
xyzCreation ->
while (counter < 2){
def Params1 = 'field1'+counter
def Params2 = 'field2' +counter
def Params3 = 'field3' +counter
def Params4 = 'field4' +counter
xyzTracking = new XYZTracking()
xyzTracking.d = params[Params1]
xyzTracking.e = params[Params2]
xyzTracking.f = params[Params3]
xyzTracking.g = params[Params4]
xyzTracking.abc = abcJob
xyzTracking.save(flush: true);
counter++;
}
}
提前致谢。非常感谢您的帮助:)