List of usage examples for org.hibernate CacheMode GET
CacheMode GET
To view the source code for org.hibernate CacheMode GET.
Click Source Link
From source file:org.candlepin.model.DetachedCandlepinQuery.java
License:Open Source License
/** * {@inheritDoc}//from ww w.ja va2 s .com */ @Override public ResultIterator<T> iterate(int column, boolean evict) { Criteria executable = this.getExecutableCriteria(); // We always override the cache mode here to ensure we don't evict things that may be in // cache from another request. if (evict) { executable.setCacheMode(CacheMode.GET); } ScrollableResults cursor = executable.scroll(ScrollMode.FORWARD_ONLY); return new ColumnarResultIterator<>(this.session, cursor, column, evict); }
From source file:org.hyperic.hq.events.server.session.AlertDefinitionDAO.java
License:Open Source License
/** * Get a list of all alert definitions with an availability metric condition * @return a list of alert definitions//from w ww. j ava 2s. com */ public List<AlertDefinition> findAvailAlertDefs() { // To improve performance, need to explicitly fetch the resource, // resource type, and conditions so that they are not lazy loaded String hql = new StringBuilder(256).append("from AlertDefinition ad ").append("join fetch ad.resource rez ") .append("join fetch rez.resourceType ").append("join fetch ad.conditionsBag c ") .append("where ad.active = true ").append("and ad.deleted = false ").append("and upper(c.name) = '") .append(MeasurementConstants.CAT_AVAILABILITY.toUpperCase()).append("' ") .append("and (ad.parent is null or ad.parent.id != 0) ").toString(); // setCacheMode(CacheMode.GET) to prevent objects with incomplete collections from // getting cached in the 2nd level cache. return getSession().createQuery(hql).setCacheMode(CacheMode.GET).list(); }
From source file:org.osiam.storage.dao.GetInternalIdSkeleton.java
License:Open Source License
protected <T> SCIMSearchResult<T> search(Class<T> clazz, String filter, int count, int startIndex, String sortBy, String sortOrder) { Session session = (Session) em.getDelegate(); Criteria criteria = session.createCriteria(clazz); criteria.setReadOnly(true);// w w w . ja v a2s .co m criteria.setCacheMode(CacheMode.GET); criteria.setCacheable(true); if (filter != null && !filter.isEmpty()) { criteria = criteria.add(filterParser.parse(filter).buildCriterion()); } createAliasesForCriteria(criteria); criteria.setMaxResults(count); long totalResult = getTotalResults(criteria); setSortOrder(sortBy, sortOrder, criteria); criteria.setFirstResult(startIndex); Criteria criteria1 = criteria.setProjection(null).setResultTransformer(Criteria.ROOT_ENTITY); List list = criteria1.list(); return new SCIMSearchResult(list, totalResult); }
From source file:org.sakaiproject.profile2.dao.impl.ProfileDaoImpl.java
License:Educational Community License
/** * {@inheritDoc}/*from w ww. j a v a2 s . com*/ */ public List<UserProfile> getUserProfiles(final int start, final int count) { //get fields directly from the sakaiperson table and use Transformers.aliasToBean to transform into UserProfile pojo //the idea is we *dont* want a SakaiPerson object HibernateCallback hcb = new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Query q = session.getNamedQuery(QUERY_GET_SAKAI_PERSON); //see scalars in the hbm q.setFirstResult(start); q.setMaxResults(count); q.setResultTransformer(Transformers.aliasToBean(UserProfile.class)); q.setCacheMode(CacheMode.GET); return q.list(); } }; return (List<UserProfile>) getHibernateTemplate().executeFind(hcb); }
From source file:se.vgregion.webbisar.svc.impl.WebbisDaoHibernate.java
License:Open Source License
/** * {@inheritDoc}//from ww w. jav a 2s . c o m */ public void reindex() { getJpaTemplate().execute(new JpaCallback() { public Object doInJpa(EntityManager em) throws PersistenceException { FullTextSession fullTextSession = getFullTextSession(getHibernateSession(em)); fullTextSession.purgeAll(Webbis.class); // Do not update the second level cache. It will just slow things down. fullTextSession.setCacheMode(CacheMode.GET); // Read 5000 entries at a time. final int BATCH_SIZE = 5000; // Due to a bug in Hibernate (HHH-1283) a join does not work here. // See http://opensource.atlassian.com/projects/hibernate/browse/HHH-1283 ScrollableResults results = fullTextSession.createQuery("from Webbis w").scroll(); int index = 0; while (results.next()) { index++; fullTextSession.index(results.get(0)); // index each element if (index % BATCH_SIZE == 0) { fullTextSession.flushToIndexes(); // apply changes to indexes fullTextSession.clear(); // clear since the queue is processed } } return null; } }); }