Hello there,
I'll need to copy thousands of objects from one table to another; the copying'll be almost verbatim, but for a relationship. Namely,
entity OldAuction <->> OldRecord (relationships records->> and inverse <-auction)
entity NewAuction <->> NewRecord (relationships records->> and inverse <-newAuction)
Entity NewRecord has all attributes of OldRecord (and perhaps a couple of others)
The naïve code would be something like
===
def orig=... an object of the OldAuction entity ...
def new=... an object of the NewAuction entity ...
orig.allRecords().each { OldRecord old ->
def newRecord=EOUtilities.createAndInsertInstance(new.editingContext(),'NewRecord')
newRecord.newAuction=new
newRecord.takeValuesFromDictionary(old.valuesForKeys(old.attributeKeys()))
}
new.editingContext().saveChanges()
===