List of usage examples for org.hibernate CacheMode IGNORE
CacheMode IGNORE
To view the source code for org.hibernate CacheMode IGNORE.
Click Source Link
From source file:com.kanjiportal.portal.admin.LuceneManagementAction.java
License:Open Source License
public void reIndexDictionary() { FullTextSession fullTextSession = (FullTextSession) entityManager.getDelegate(); fullTextSession.setFlushMode(FlushMode.MANUAL); fullTextSession.setCacheMode(CacheMode.IGNORE); long beforeDictionary = System.currentTimeMillis(); //Scrollable results will avoid loading too many objects in memory ScrollableResults results = fullTextSession.createCriteria(Dictionary.class).setFetchSize(BATCH_SIZE) .setFetchMode("translations", FetchMode.JOIN).setFetchMode("translations.language", FetchMode.JOIN) .scroll(ScrollMode.FORWARD_ONLY); int index = 0; while (results.next()) { index++;/* w ww. j a v a2 s . com*/ fullTextSession.index(results.get(0)); //index each element if (index % BATCH_SIZE == 0) { entityManager.flush(); entityManager.clear(); log.debug("flush()"); } } log.debug("Indexing dictionary done"); long afterDictionary = System.currentTimeMillis(); facesMessages.add("Dictionary Indexing done in #0 ms", afterDictionary - beforeDictionary); }
From source file:com.leixl.easyframework.lucene.impl.LuceneEMovieDaoImpl.java
License:Open Source License
public Integer index(IndexWriter writer, Date startDate, Date endDate, Integer startId, Integer max) throws CorruptIndexException, IOException { Finder f = Finder.create("select bean from EMovie bean"); f.append(" where 1=1"); if (startId != null) { f.append(" and bean.id > :startId"); f.setParam("startId", startId); }//from w w w .ja v a 2s .c o m if (startDate != null) { f.append(" and bean.createDate >= :startDate"); f.setParam("startDate", startDate); } if (endDate != null) { f.append(" and bean.createDate <= :endDate"); f.setParam("endDate", endDate); } f.append(" order by bean.id asc"); if (max != null) { f.setMaxResults(max); } Session session = getSession(); ScrollableResults movies = f.createQuery(getSession()).setCacheMode(CacheMode.IGNORE) .scroll(ScrollMode.FORWARD_ONLY); int count = 0; EMovie movie = null; while (movies.next()) { movie = (EMovie) movies.get(0); writer.addDocument(LuceneContent.createDocument(movie)); if (++count % 20 == 0) { session.clear(); } } if (count < max || movie == null) { // ???????? return null; } else { // ?ID return movie.getId(); } }
From source file:com.model.dao.DepartmentDao.java
public static boolean addDepartment(Department d) { boolean result = false; Session session = HibernateUtil.getSessionFactory().openSession(); session.setCacheMode(CacheMode.IGNORE); Transaction tx = null;/*from www .j a v a 2s. com*/ try { tx = session.beginTransaction(); session.save(d); tx.commit(); result = true; } catch (HibernateException ex) { if (tx != null) { tx.rollback(); result = false; } ex.printStackTrace(); } finally { session.close(); } return result; }
From source file:com.model.dao.DepartmentDao.java
public static boolean updateDepartment(Department d) { boolean result = false; Session session = HibernateUtil.getSessionFactory().openSession(); session.setCacheMode(CacheMode.IGNORE); Transaction tx = null;/* w w w .j av a2 s . c o m*/ try { tx = session.beginTransaction(); session.update(d); tx.commit(); result = true; } catch (HibernateException ex) { if (tx != null) { tx.rollback(); result = false; } ex.printStackTrace(); } finally { session.close(); } return result; }
From source file:com.model.dao.DepartmentDao.java
public static boolean deleteDepartment(Department d) { boolean result = false; Session session = HibernateUtil.getSessionFactory().openSession(); session.setCacheMode(CacheMode.IGNORE); Transaction tx = null;/* w w w . j a v a 2 s. c o m*/ try { tx = session.beginTransaction(); session.delete(d); tx.commit(); result = true; } catch (HibernateException ex) { if (tx != null) { tx.rollback(); result = false; } ex.printStackTrace(); } finally { session.close(); } return result; }
From source file:com.model.dao.DepartmentDao.java
public static List<Department> list() { List<Department> result = null; Session session = HibernateUtil.getSessionFactory().openSession(); session.setCacheMode(CacheMode.IGNORE); Transaction tx = null;/* ww w . j a v a 2 s .c o m*/ try { tx = session.beginTransaction(); result = session.createQuery("from com.model.entity.Department").list(); tx.commit(); } catch (HibernateException ex) { if (tx != null) { tx.rollback(); } ex.printStackTrace(); } finally { session.close(); } return result; }
From source file:com.model.dao.EmployeeDao.java
public static boolean addEmploye(Employee e) { boolean result = false; Session session = HibernateUtil.getSessionFactory().openSession(); session.setCacheMode(CacheMode.IGNORE); Transaction tx = null;/*from ww w . j a v a 2 s. c o m*/ try { tx = session.beginTransaction(); session.merge(e); tx.commit(); result = true; } catch (HibernateException ex) { if (tx != null) { tx.rollback(); result = false; } ex.printStackTrace(); } finally { session.close(); } return result; }
From source file:com.model.dao.EmployeeDao.java
public static boolean deleteEmploye(Employee e) { boolean result = false; Session session = HibernateUtil.getSessionFactory().openSession(); session.setCacheMode(CacheMode.IGNORE); Transaction tx = null;//from ww w. j a v a2s . c om try { tx = session.beginTransaction(); session.delete(e); tx.commit(); result = true; } catch (HibernateException ex) { if (tx != null) { tx.rollback(); result = false; } ex.printStackTrace(); } finally { session.close(); } return result; }
From source file:com.model.dao.EmployeeDao.java
public static boolean updateEmploye(Employee e) { boolean result = false; Session session = HibernateUtil.getSessionFactory().openSession(); session.setCacheMode(CacheMode.IGNORE); Transaction tx = null;//w w w . j ava2 s . c o m try { tx = session.beginTransaction(); session.update(e); tx.commit(); result = true; } catch (HibernateException ex) { if (tx != null) { tx.rollback(); result = false; } ex.printStackTrace(); } finally { session.close(); } return result; }
From source file:com.model.dao.EmployeeDao.java
public static List<Employee> list() { Session session = HibernateUtil.getSessionFactory().openSession(); session.setCacheMode(CacheMode.IGNORE); Transaction tx = null;/* w ww .j a v a 2 s. c o m*/ List<Employee> result = null; try { tx = session.beginTransaction(); result = session.createQuery("FROM Employee").list(); tx.commit(); } catch (HibernateException ex) { if (tx != null) { tx.rollback(); } ex.printStackTrace(); } finally { session.close(); } return result; }