List of usage examples for org.hibernate Session setCacheMode
void setCacheMode(CacheMode cacheMode);
From source file:com.adsapient.shared.dao.HibernateEntityDao.java
License:Open Source License
public void updateObject(final Object obj) { getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { session.setCacheMode(CacheMode.IGNORE); session.update(obj);//w w w.j a v a2 s. c o m sendUpdateEventToAdserver(obj.getClass(), ((IMappable) obj).getId(), null); return obj; } }); }
From source file:com.adsapient.shared.dao.HibernateEntityDao.java
License:Open Source License
public Collection viewAll(final Class objClass) { return (List) getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { session.setCacheMode(CacheMode.IGNORE); return session.createCriteria(objClass).list(); }/*from www. ja v a 2s .c o m*/ }); }
From source file:com.adsapient.shared.dao.HibernateEntityDao.java
License:Open Source License
public Collection viewAllWithOrder(final Class className, final String orderFieldName) { return (Collection) getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { session.setCacheMode(CacheMode.IGNORE); return session.createCriteria(className).addOrder(Order.asc(orderFieldName)).list(); }/*from ww w. ja v a 2 s .c o m*/ }); }
From source file:com.adsapient.shared.dao.HibernateEntityDao.java
License:Open Source License
public Collection viewWithCriteria(final Class hibernateObjectClass, final String criteriaName, final Object criteriaValue, final String orderField) { Collection coll = (Collection) getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { session.setCacheMode(CacheMode.IGNORE); return session.createCriteria(hibernateObjectClass) .add(Expression.like(criteriaName, criteriaValue)).addOrder(Order.asc(orderField)).list(); }// ww w .j ava 2 s. c om }); if (coll == null) coll = new ArrayList(); return coll; }
From source file:com.adsapient.shared.dao.HibernateEntityDao.java
License:Open Source License
public Collection viewWithCriteriaNot(final Class hibernateObjectClass, final String criteriaName, final Object criteriaValue) { Collection coll = (Collection) getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { session.setCacheMode(CacheMode.IGNORE); return session.createCriteria(hibernateObjectClass).add(Expression.ne(criteriaName, criteriaValue)) .list();//from ww w . jav a2 s . co m } }); if (coll == null) coll = new ArrayList(); return coll; }
From source file:com.adsapient.shared.dao.HibernateEntityDao.java
License:Open Source License
public Collection viewWithCriteria(final Class hibernateObjectClass, final String criteriaName1, final Object criteriaValue1, final String criteriaName2, final Object criteriaValue2) { return (Collection) getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { session.setCacheMode(CacheMode.IGNORE); Criteria crit = session.createCriteria(hibernateObjectClass); if (criteriaValue1 == null) { crit.add(Expression.isNull(criteriaName1)); } else { crit.add(Expression.eq(criteriaName1, criteriaValue1)); }/*from w w w. j a v a 2s . c o m*/ if (criteriaValue2 == null) { crit.add(Expression.isNull(criteriaName2)); } else { crit.add(Expression.eq(criteriaName2, criteriaValue2)); } return crit.list(); } }); }
From source file:com.adsapient.shared.dao.HibernateEntityDao.java
License:Open Source License
public Collection viewWithCriteria(final Class hibernateObjectClass, final Object[] criteriaParams) { return (Collection) getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { session.setCacheMode(CacheMode.IGNORE); Criteria critiria = session.createCriteria(hibernateObjectClass); for (int i = 0; i < criteriaParams.length; i += 2) { critiria.add(Expression.eq((String) criteriaParams[i], criteriaParams[i + 1])); }// ww w.j av a 2 s .co m return critiria.list(); } }); }
From source file:com.adsapient.shared.dao.HibernateEntityDao.java
License:Open Source License
public Collection viewWithNullCriteria(final Class hibernateObjectClass, final String criteriaName, final boolean isNull) { return (Collection) getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { session.setCacheMode(CacheMode.IGNORE); Criteria critiria = session.createCriteria(hibernateObjectClass); if (isNull) critiria.add(Expression.isNull(criteriaName)); else// w w w . j a v a2 s .c o m critiria.add(Expression.isNotNull(criteriaName)); return critiria.list(); } }); }
From source file:com.adsapient.shared.dao.HibernateEntityDao.java
License:Open Source License
public List getBannerList(final Integer status) { return (List) getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { session.setCacheMode(CacheMode.IGNORE); Query query = session.getNamedQuery("loadBanners").setInteger("STATUS", status); return query.list(); }/* www .j av a2s .com*/ }); }
From source file:com.adsapient.shared.dao.HibernateEntityDao.java
License:Open Source License
public Integer executeQueryUpdate(final String queryName) { return (Integer) getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { session.setCacheMode(CacheMode.IGNORE); Transaction tx = session.beginTransaction(); Query query = session.getNamedQuery(queryName); Integer res = query.executeUpdate(); tx.commit();//from w w w.jav a2 s . co m return res; } }); }