I am creating a lot of objects and I am trying to get a bit of a performance boost. Currently I have an assignment for a gorm object attribute that I could get better performance out of if I could set the foreign key manually.
def oldBook = Book.findByTitle("Of Mice and Men") def newBook = new Book() newBook.author = oldBook.author //This line could be faster
The line that could be faster if it didn't have to look up the author object on the oldBook. Ideally the line would look more like this. (fyi these don't actually work)
newBook.authorId = oldBook.authorId // or newBook.setAuthorId(oldBook.authorId)
Is something like this possible in grails? Perhaps it's possible but dangerous. I'm using version grails 2.2.1, Hibernate, and Oracle. The only other thought I had on this is I could eagerly load the author object.