jodd-db/src/main/java/jodd/db/oom/mapper/DefaultResultSetMapper.java
protected void cacheResultSetEntities(final Object[] result) {
		if (entitiesCache == null) {
			entitiesCache = new HashMap<>();
		}

		for (int i = 0; i < result.length; i++) {
			Object object = result[i];

			if (object == null) {
				continue;
			}

			DbEntityDescriptor ded = cachedDbEntityDescriptors[i];

			if (ded == null) {	// not a type, continue
				continue;
			}

			// calculate key
			Object key;
			if (ded.hasIdColumn()) {
				//noinspection unchecked
				key = ded.getKeyValue(object);
			} else {
				key = object;
			}

			Object cachedObject = entitiesCache.get(key);

			if (cachedObject == null) {
				// object is not in the cache, add it
				entitiesCache.put(key, object);
			} else {
				// object is in the cache, replace it
				result[i] = cachedObject;
			}
		}
	}
protected void cacheResultSetEntities(final Object[] result) {
		if (entitiesCache == null) {
			entitiesCache = new HashMap<>();
		}

		for (int i = 0; i < result.length; i++) {
			Object object = result[i];

			if (object == null) {
				continue;
			}

			DbEntityDescriptor ded = cachedDbEntityDescriptors[i];

			if (ded == null) {	// not a type, continue
				continue;
			}

			// calculate key
			Object key;
			if (ded.hasIdColumn()) {
				//noinspection unchecked
				key = ded.getKeyValue(object);
			} else {
				key = object;
			}

			Object cachedObject = entitiesCache.get(key);

			if (cachedObject == null) {
				// object is not in the cache, add it
				entitiesCache.put(key, object);
			} else {
				// object is in the cache, replace it
				result[i] = cachedObject;
			}
		}
	}
Caches returned entities. Replaces new instances with existing ones.