duplicate() interferes with hibernate session: LazyInitializationException


I think this is a bug in ACF as well and it's been around forever. It's frustrating to reproduce and we've been moving away from Hibernate/CFORM anyway, but I wanted to log it in the event somebody else comes across it.

If you have Hibernate enabled, and possibly just with second-level caching, it is possible, though not guaranteed, that any duplicate() call ... anywhere, totally unrelated to ORM entities ... will result in an error like this:

This error was prompted by calling duplicate() on a QueryBuilder object (forgebox.io/view/qb) that had not yet executed any queries, and which had nothing to do with the lotteryDrawExtra entity. There were probably some unrelated hibernate calls made in bootstrapping the request, but they had no connection to the object being duplicated and no reference to LotteryDrawExtra – which is to say, there probably was a hibernate session, but not one having anything to do with LotteryDrawExtra.

We've seen this error a dozen times over the years and it took us weeks to trace it to duplicate(), first on ACF11 and then on Lucee. Our workaround is to avoid duplicate() until we can retire CFORM entirely. It's unlikely that we will be able to produce a reliable test case anytime soon, but anybody converting legacy apps with CFORM may encounter this and can chime in when they do!






Samuel W. Knowlton




Fix versions


Affects versions