Tabnine Logo
Criteria.setCacheMode
Code IndexAdd Tabnine to your IDE (free)

How to use
setCacheMode
method
in
org.hibernate.Criteria

Best Java code snippets using org.hibernate.Criteria.setCacheMode (Showing top 10 results out of 315)

origin: hibernate/hibernate-orm

  @Override
  protected Object getResults(Session s, boolean isSingleResult) throws Exception {
    Criteria criteria = getCriteria( s ).setCacheable( getQueryCacheMode() != CacheMode.IGNORE ).setCacheMode( getQueryCacheMode() );
    return ( isSingleResult ? criteria.uniqueResult() : criteria.list() );
  }
}
origin: openmrs/openmrs-core

/**
 * Create the criteria for fetching all encounters based on cohort
 *
 * @param patients
 * @return a map of patient with their encounters
 */
private Criteria createEncounterCriteria(Cohort patients) {
  Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Encounter.class);
  criteria.setCacheMode(org.hibernate.CacheMode.IGNORE);
  
  // only include this where clause if patients were passed in
  if (patients != null) {
    ArrayList<Integer> patientIds = new ArrayList<>();
    patients.getMemberships().forEach(m -> patientIds.add(m.getPatientId()));
    criteria.add(Restrictions.in("patient.personId", patientIds));
  }
  
  criteria.add(Restrictions.eq("voided", false));
  
  criteria.addOrder(Order.desc("patient.personId"));
  criteria.addOrder(Order.desc("encounterDatetime"));
  return criteria;
}

origin: TGAC/miso-lims

@Override
public Criteria setCacheMode(CacheMode cacheMode) {
 backingCriteria.setCacheMode(cacheMode);
 return this;
}
origin: stackoverflow.com

 public CriteriaReportSource(Criteria c) {
  this.c = c;
  this.sr = c.setCacheMode(CacheMode.IGNORE)
        .scroll(ScrollMode.FORWARD_ONLY);
}


public boolean next() {
  if (sr.next()) {
    currentObject = sr.get(0);
    return true;
  }
  return false;
}
origin: ezbz/projectx

@Override
public Criteria setCacheMode(final CacheMode cacheMode) {
 return criteria.setCacheMode(cacheMode);
}
origin: com.github.mrstampy/hit

/**
 * Sets the specified criteria cacheable with NORMAL cache mode.
 * 
 * @param c
 */
protected void setCacheable(Criteria c) {
 c.setCacheable(true);
 c.setCacheMode(CacheMode.NORMAL);
}
origin: openmrs/openmrs-module-webservices.rest

/**
 * @see org.openmrs.module.webservices.rest.web.api.RestHelperService#getPatients(Collection)
 */
@Override
@SuppressWarnings("unchecked")
public List<Patient> getPatients(Collection<Integer> patientIds) {
  List<Patient> ret = new ArrayList<Patient>();
  
  if (!patientIds.isEmpty()) {
    Criteria criteria = getSession().createCriteria(Patient.class);
    criteria.setCacheMode(CacheMode.IGNORE);
    criteria.add(Restrictions.in("patientId", patientIds));
    criteria.add(Restrictions.eq("voided", false));
    List<Patient> temp = criteria.list();
    for (Patient p : temp) {
      ret.add(p);
    }
  }
  
  return ret;
}

origin: at.chrl/chrl-orm

/**
 * crates a Stream with given {@link Criteria} crit
 * 
 * @param crit
 *            - given Criteria
 * @return new {@link Stream} with given ResultSet
 */
public <T> Stream<T> stream(Criteria crit) {
  if(TransactionStatus.NOT_ACTIVE.equals(session.getTransaction().getStatus()))
    session.beginTransaction();
  if (loggingEnabled)
    logQuery(false);
  
  return StreamSupport.<T> stream(Spliterators.spliteratorUnknownSize(
      new QueryIterator<T>(crit.setCacheMode(CacheMode.IGNORE)
          .setFlushMode(FlushMode.MANUAL), this, false),
      Spliterator.ORDERED | Spliterator.DISTINCT), false);
}
origin: hibernate/hibernate-search

.setLockMode( LockMode.NONE )
.setFlushMode( FlushMode.MANUAL )
.setCacheMode( cacheMode )
.setFetchSize( entityFetchSize )
.scroll( ScrollMode.FORWARD_ONLY );
origin: sk.seges.corpis/corpis-dao-impl

@SuppressWarnings("unchecked")
private List<T> doFindByCriteria(DetachedCriteria criteria, Page page, Set<String> existingAliases,
    boolean addFilterables, boolean cacheable) {
  Criteria executable = criteria.getExecutableCriteria((Session) entityManager.getDelegate());
  if (existingAliases != null) {
    if (addFilterables) {
      enrichCriteriaWithFilterables(page, executable, existingAliases);
    }
    // projectables are needed only forexecutable final select, not for
    // count
    enrichCriteriaWithProjectables(page, executable, existingAliases);
  }
  enrichCriteriaWithSortables(page, executable, existingAliases);
  executable.setFirstResult(page.getStartIndex());
  if (!retrieveAllResults(page)) {
    // Restrict the selection only when page size has meaningful value.
    executable.setMaxResults(page.getPageSize());
  }
  executable.setCacheable(cacheable);
  if (cacheable) {
    executable.setCacheMode(CacheMode.NORMAL);
  }
  List<T> list = setSpecialSortCriteria(executable);
  if (list != null){
    return list;
  }
  return executable.list();
}

org.hibernateCriteriasetCacheMode

Javadoc

Override the cache mode for this particular query.

Popular methods of Criteria

  • list
    Get the results.
  • add
    Add a Criterion to constrain the results to be retrieved.
  • uniqueResult
    Convenience method to return a single instance that matches the query, or null if the query returns
  • addOrder
    Add an Order to the result set.
  • setProjection
    Used to specify that the query results will be a projection (scalar in nature). Implicitly specifies
  • setMaxResults
    Set a limit upon the number of objects to be retrieved.
  • setFirstResult
    Set the first result to be retrieved.
  • setResultTransformer
    Set a strategy for handling the query results. This determines the "shape" of the query result.
  • createAlias
    Join an association using the specified join-type, assigning an alias to the joined association. The
  • createCriteria
    Create a new Criteria, "rooted" at the associated entity, using the specified join type.
  • setFetchMode
    Specify an association fetching strategy for an association or a collection of values.
  • setCacheable
    Enable caching of this query result, provided query caching is enabled for the underlying session fa
  • setFetchMode,
  • setCacheable,
  • setFetchSize,
  • scroll,
  • setLockMode,
  • setReadOnly,
  • setCacheRegion,
  • setTimeout,
  • setFlushMode

Popular in Java

  • Finding current android device location
  • setScale (BigDecimal)
  • getApplicationContext (Context)
  • getResourceAsStream (ClassLoader)
  • Menu (java.awt)
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • Sublime Text for Python
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now