I'm reading an Excel file with a 'for loop'. And I have no problem persisting 3 different instances of different classes that represents the firsts set of columns in the excel file.
But when I try to "while-loop" the next columns that represent a dynamic range of other objects I can't get them to persist in the DB. Nor with flush:true or anything.
for (int r = 6; r < sheet.rows; r++)
{
def fooInstance = new Foo()
def barInstance = new Bar()
def fooBarInstance = new FooBar()
//Set foo, bar and fooBar Instances properties based on the excel columns
def bazIndez = 11
while(bazIndex < sheet.columns){
def bazInstance = new Baz()
//set bazInstance properties
println bazInstance //Every property is ok
println bazInstance.getErrors() //0 errors
bazInstance.save() // .save(flush:true) didn't work either
bazIndez++
}
foo.save() //No problem here
bar.save() //No problem here
fooBar.save() //No problem here
}
fooInstance, barInstance and fooBarInstance get persisted, but bazInstance never is.
Note 1: All these object have no relationship with each other or with any other class.
Note 2: All these objects use composite id and "id generator: 'assigned'"
Grails 1.3.9 JDK 1.6
Thanks in advance.