org.omnifaces.persistence.service.EclipseLinkRoot Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of omnipersistence Show documentation
Show all versions of omnipersistence Show documentation
Utilities for JPA, JDBC and DataSources
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