All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.omnifaces.persistence.service.EclipseLinkRoot Maven / Gradle / Ivy

There is a newer version: 0.22.J1
Show newest version
package org.omnifaces.persistence.service;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.criteria.Fetch;
import javax.persistence.criteria.Root;

/**
 * EclipseLink stubbornly refuses to perform a join when a range (offset/limit) is fetched, resulting in cartesian products.
 * This root will postpone all issued fetches so BaseEntityService can ultimately set them as an EclipseLink-specific query hint.
 * The only disadvantage is that you cannot anymore sort on them when used in a lazy model. This is a technical limitation.
 */
class EclipseLinkRoot extends RootWrapper {

	private Set postponedFetches;

	public EclipseLinkRoot(Root wrapped) {
		super(wrapped);
		postponedFetches = new HashSet<>(2);
	}

	@Override
	@SuppressWarnings({ "unchecked", "hiding" })
	public  Fetch fetch(String attributeName) {
		postponedFetches.add(attributeName);
		return null;
	}

	public Set getPostponedFetches() {
		return postponedFetches;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy