/** * INTERNAL: * Creates and returns a copy of this query. * @return A clone of this instance. */ @Override public Object clone() { final ObjectLevelReadQuery cloneQuery = (ObjectLevelReadQuery)super.clone(); // Must also clone the joined expressions as always joined attribute will be added // don't use setters as this will trigger unprepare. if (joinedAttributeManager != null) { cloneQuery.joinedAttributeManager = joinedAttributeManager.clone(); cloneQuery.joinedAttributeManager.setBaseQuery(cloneQuery); } if (this.batchFetchPolicy != null) { cloneQuery.batchFetchPolicy = batchFetchPolicy.clone(); } if (this.nonFetchJoinAttributeExpressions != null){ cloneQuery.nonFetchJoinAttributeExpressions = new ArrayList<>(nonFetchJoinAttributeExpressions); } // Don't use setters as that will trigger unprepare if (this.orderByExpressions != null) { cloneQuery.orderByExpressions = new ArrayList<>(this.orderByExpressions); } if (this.fetchGroup != null) { cloneQuery.fetchGroup = fetchGroup.clone(); // don't clone immutable entityFetchGroup } return cloneQuery; }
/** * INTERNAL: * Clone the query */ @Override public Object clone() { ObjectLevelReadQuery cloneQuery = (ObjectLevelReadQuery)super.clone(); // Must also clone the joined expressions as always joined attribute will be added // don't use setters as this will trigger unprepare. if (this.joinedAttributeManager != null) { cloneQuery.joinedAttributeManager = this.joinedAttributeManager.clone(); cloneQuery.joinedAttributeManager.setBaseQuery(cloneQuery); } if (this.batchFetchPolicy != null) { cloneQuery.batchFetchPolicy = this.batchFetchPolicy.clone(); } if (this.nonFetchJoinAttributeExpressions != null){ cloneQuery.nonFetchJoinAttributeExpressions = new ArrayList<Expression>(this.nonFetchJoinAttributeExpressions); } // Don't use setters as that will trigger unprepare if (this.orderByExpressions != null) { cloneQuery.orderByExpressions = new ArrayList<Expression>(this.orderByExpressions); } if (this.fetchGroup != null) { cloneQuery.fetchGroup = this.fetchGroup.clone(); // don't clone immutable entityFetchGroup } return cloneQuery; }
this.batchFetchPolicy = objectQuery.getBatchFetchPolicy().clone();
this.batchFetchPolicy = objectQuery.getBatchFetchPolicy().clone();