/** * Creates a copy of this LoadContext instance. */ public LoadContext<?> copy() { LoadContext<?> ctx; try { ctx = getClass().newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new RuntimeException("Error copying LoadContext", e); } ctx.metaClass = metaClass; ctx.setQuery(query != null ? query.copy() : null); ctx.view = view; ctx.id = id; ctx.softDeletion = softDeletion; ctx.prevQueries.addAll(prevQueries.stream().map(Query::copy).collect(Collectors.toList())); ctx.queryKey = queryKey; if (dbHints != null) { ctx.getDbHints().putAll(dbHints); } ctx.loadDynamicAttributes = loadDynamicAttributes; ctx.authorizationRequired = authorizationRequired; ctx.joinTransaction = joinTransaction; return ctx; }