com.arch.util.CachedUtils Maven / Gradle / Ivy
package com.arch.util;
import org.hibernate.jpa.QueryHints;
import javax.persistence.Cacheable;
import javax.persistence.TypedQuery;
public final class CachedUtils {
private CachedUtils() {
}
public static TypedQuery createQueryCache(Class> clazz, TypedQuery query) {
if (!cached(clazz)) {
return query;
}
return query.setHint(QueryHints.HINT_CACHEABLE, true);
}
public static TypedQuery forceCache(TypedQuery query) {
return query.setHint(QueryHints.HINT_CACHEABLE, true);
}
public static boolean cached(Class> clazz) {
Cacheable cacheable = clazz.getAnnotation(Cacheable.class);
return cacheable != null && cacheable.value();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy