Query Explosion

Sorry for the dramatic title, but it is descriptive.

Seemingly randomly, Eclipse link will attempt to load an entity’s entire graph from the database simultaneously which triggers the org.postgresql.util.PSQLException: ERROR: target lists can have at most 1664 entries. I haven’t pin able to pin down exactly what is causing the exception because it occurs inconsistently and against multiple entities. Attached is the stack trace with the ludicrously large query. Any insight regarding why this is happening and how to prevent it would be much appreciated.

stacktrace.txt (144.4 KB)

It can be the same problem as discussed here for Jmix: Too many tables; MySQL can only use 61 tables in a join - Support - Jmix

Workarounds should also apply.