0

I'm working with the ORM framework of coldfusion and found an error I cannot get past. I found another stackoverflow thread stating that you can use duplicate on a entityNew() object. This works perfectly. I can save the object as a new row, and it's a nice duplicate. BUT when I do the exact same thing while it's an existing entity. It gives an error. "failed to lazily initialize a collection". I tried everything with entityReload and entityMerge. Entitymerge just overwrites the other object (while using forseinsert on entitySave???)

So I think something is not working right here. Can somebody point me in the right direction why this error is occuring? Thanks in advance!

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
RolandMakkelie
  • 355
  • 3
  • 14
  • Have you tried `ORMFlush()` ? – James A Mohler Jan 16 '18 at 14:46
  • Hey, thanks for the fast response. But no still getting "failed to lazily initialize a collection, no session or session was closed". In the entity I try to duplicate are some relationships. These relationships cause this error, that's what I know. But why it has no problem with entityNew() and has a problem with entityLoadByPK() is something I don't understand. – RolandMakkelie Jan 16 '18 at 15:08
  • Seems to be related to this: https://helpx.adobe.com/coldfusion/developing-applications/coldfusion-orm/performance-optimization/lazy-loading.html and this https://stackoverflow.com/questions/11746499/solve-failed-to-lazily-initialize-a-collection-of-role-exception – James A Mohler Jan 16 '18 at 17:24

0 Answers0