There is no infinite loop.
The stacktrace above is from the "Profile" controller, factory and model.
The code is generated by a Gradle plugin that we have written.
This Gradle plugin also generates the same structured code for the "User" controller, factory and model. Which works fine. (i.e. Does not throw a DependencyLoopException.)
The situation gets even more complicated (and I left it out initially as I had hoped to find a solution without complicating things).
This is part of a Ktor web application. Once I run the application and login through Chrome, if I access the "Profile" first it throws this exception.
Instead, if I run the application, login and access the "User" first, the "Profile" then works (and keeps working until I restart the application).
This seems wierd to me, but there is a link (in the database structure) from the "ProfileVersion" to the "User.
So I thought that might be the cause, until I noticed a link (in the database structure) from the "UserVersionProfile" to the "Profile".
We have created another project which extends this project, written additional database structure, which the Gradle plugin uses to generate the same structured controller, factory and model for other tables.
These tables have the link to the "User", but I get the DependencyLoopException even if I access the "User" first.
I have been trying to work out how to remove the dependency loop, but am having trouble. I will see how I go.