List of usage examples for org.hibernate Query setCacheable
Query<R> setCacheable(boolean cacheable);
From source file:net.commerce.zocalo.hibernate.HibernateUtil.java
License:Open Source License
public static MultiMarket getMultiMarketByName(String name) { Session session = currentSession();/*from w w w . j a va2 s .c o m*/ Query mQ = session.createQuery( "select m from MultiMarket m " + "join m.claim c " + "where m.claim = c.id and c.name = :name"); mQ.setString("name", name); mQ.setCacheable(true); return (MultiMarket) mQ.uniqueResult(); }
From source file:net.commerce.zocalo.hibernate.HibernateUtil.java
License:Open Source License
public static List couponOwners(Claim claim) { Session session = currentSession();//from ww w . ja v a 2 s .c o m //TODO: I can't see how to access the Claims that are the keys of acct's positions map. //TODO: that would require two fewer joins! //select owner.user_id" + //from public.USER owner, public.accounts acct, PUBLIC.ACCOUNT_HOLDINGS assets, PUBLIC.POSITIONS pos " + // where owner.accounts = acct.accounts_id" + // and acct.accounts_id = assets.accounts_id" // and assets.POSITIONS_ID = pos.positions_id " + // and pos.claims_ID=2 " + Query qa = session.createQuery("select u \n" + "from SecureUser u \n" + " join u.accounts acct\n" + " join acct.positions coupon \n" + "where u.accounts = acct.id and coupon.position.claim = :claim "); qa.setEntity("claim", claim); qa.setCacheable(true); return qa.list(); }
From source file:net.commerce.zocalo.hibernate.HibernateUtil.java
License:Open Source License
public static List getOrdersForUser(User user) { Query query = currentSession().createQuery( "select o from Order o " + "join o.owner u " + "where o.owner = u.id and u.name = :name"); query.setString("name", user.getName()); query.setCacheable(true); return query.list(); }
From source file:net.commerce.zocalo.hibernate.HibernateUtil.java
License:Open Source License
static public List getTrades(SecureUser user) { Query query = currentSession().createQuery("select t from Trade t " + "join t.pos p " + "join p.claim cl " + "where t.pos = p.id and t.owner = :name " + "order by cl.id, t.time"); query.setString("name", user.getName()); query.setCacheable(true); return query.list(); }
From source file:net.commerce.zocalo.hibernate.HibernateUtil.java
License:Open Source License
public static List getTrades(SecureUser user, Market market) { Query query = currentSession().createQuery("select t from Trade t " + "join t.pos p " + "join p.claim cl " + "where t.pos = p.id and t.owner = :name and cl.name = :claimName " + "order by t.time desc"); query.setString("name", user.getName()); query.setString("claimName", market.getName()); query.setCacheable(true); return query.list(); }
From source file:net.commerce.zocalo.hibernate.HibernateUtil.java
License:Open Source License
public static List getRedemptions(SecureUser user, Market market) { Query query = currentSession().createQuery("select r from Redemption r " + "join r.pos p " + "join p.claim cl " + "where r.pos = p.id and r.owner = :name and cl.name = :claimName "); query.setString("name", user.getName()); query.setCacheable(true); query.setString("claimName", market.getName()); query.setCacheable(true);//from w ww. j a va 2 s. c o m return query.list(); }
From source file:net.databinder.models.hib.HibernateListModel.java
License:Open Source License
/** * Contructor for a simple query.// w ww . j a v a 2s .c o m * @param queryString query with no parameters * @param cacheable sets query to cacheable if true */ public HibernateListModel(String queryString, final boolean cacheable) { this(queryString, new QueryBinder() { public void bind(Query query) { query.setCacheable(cacheable); } }); }
From source file:net.sf.ehcache.hibernate.domain.EventManager.java
License:Apache License
/** * Call setEntity() on a cacheable query - see FORGE-265 */// w ww. j a v a 2 s . c om public List listEventsOfOrganizer(Person organizer) { Session session = sessionFactory.getCurrentSession(); session.beginTransaction(); Query query = session.createQuery("from Event ev where ev.organizer = :organizer"); query.setCacheable(true); query.setEntity("organizer", organizer); List result = query.list(); session.getTransaction().commit(); return result; }
From source file:nl.strohalm.cyclos.dao.BaseDAOImpl.java
License:Open Source License
private void process(final Query query, final Object namedParameters) { hibernateQueryHandler.setQueryParameters(query, namedParameters); if (queryCacheRegion != null) { query.setCacheable(true); query.setCacheRegion(queryCacheRegion); }//from w w w .java2 s.c o m }
From source file:nl.strohalm.cyclos.utils.hibernate.HibernateQueryHandler.java
License:Open Source License
/** * List the query with hibernate/*from www .j a v a 2s . c om*/ */ @SuppressWarnings("unchecked") public <E> List<E> simpleList(final String cacheRegion, final String hql, final Object namedParameters, final PageParameters pageParameters, final Relationship... fetch) { final List<E> list = getHibernateTemplate().execute(new HibernateCallback<List<E>>() { //@Override public List<E> doInHibernate(final Session session) throws HibernateException { final Query query = session.createQuery(hql); setQueryParameters(query, namedParameters); applyPageParameters(pageParameters, query); if (cacheRegion != null) { query.setCacheable(true); query.setCacheRegion(cacheRegion); } return query.list(); } }); if (fetch != null && fetch.length > 0) { for (int i = 0; i < list.size(); i++) { final Entity entity = (Entity) list.get(i); list.set(i, (E) fetchDao.fetch(entity, fetch)); } } return list; }