query.setShouldMaintainCache(false);
// To avoid infinite loop clear the fetch group right away.
entity._persistence_setFetchGroup(null);
entity._persistence_setSession(null);
}
Object result = session.executeQuery(query);
if (result == null) {
// the object was not found in the db end exception will be thrown - restore the fetch group back.
if (shouldLoadResultIntoSelectionObject) {
entity._persistence_setFetchGroup(this);
entity._persistence_setSession(session);