List of usage examples for org.hibernate FlushMode MANUAL
FlushMode MANUAL
To view the source code for org.hibernate FlushMode MANUAL.
Click Source Link
From source file:ar.edu.utn.sigmaproject.webflow.Hibernate4FlowExecutionListener.java
License:Apache License
private Session createSession(RequestContext context) { final SessionBuilder sessionBuilder = sessionFactory.withOptions(); if (entityInterceptor != null) { sessionBuilder.interceptor(entityInterceptor); }//from www. j a va 2 s .c o m Session session = sessionBuilder.openSession(); session.setFlushMode(FlushMode.MANUAL); return session; }
From source file:ariba.ui.meta.jpa.HibernateContext.java
License:Apache License
protected static EntityManager createEntityManager(EntityManagerFactory factory) { EntityManager em = factory.createEntityManager(); Session session = (Session) em.getDelegate(); session.setFlushMode(FlushMode.MANUAL); return em;//w w w . j av a 2s . co m }
From source file:at.molindo.esi4j.module.hibernate.HibernateEntityResolver.java
License:Apache License
public void openResolveSession() { Session session = _localSession.get(); if (session != null) { log.warn("session already open, now closing first"); closeResolveSession();//w ww . ja v a 2 s .com session = null; } session = getNewSession(getSessionFactory()); session.setDefaultReadOnly(true); session.setCacheMode(CacheMode.GET); session.setFlushMode(FlushMode.MANUAL); session.beginTransaction(); _localSession.set(session); }
From source file:at.molindo.esi4j.module.hibernate.HibernateRebuildSession.java
License:Apache License
public HibernateRebuildSession(Class<?> type, SessionFactory sessionFactory, HibernateModule module, ScrollingSession scrollingSession) { if (type == null) { throw new NullPointerException("type"); }//from w w w .ja v a 2 s .c o m if (sessionFactory == null) { throw new NullPointerException("sessionFactory"); } if (module == null) { throw new NullPointerException("module"); } _type = type; _module = module; _scrollingSession = scrollingSession; _session = sessionFactory.openSession(); _session.setCacheMode(CacheMode.GET); _session.setDefaultReadOnly(true); _session.setFlushMode(FlushMode.MANUAL); _tx = _session.beginTransaction(); }
From source file:au.com.nicta.ct.db.CtManualFlush.java
License:Open Source License
public CtManualFlush(Session s) { this.s = s; fm = s.getFlushMode(); s.setFlushMode(FlushMode.MANUAL); }
From source file:avoking.com.documentos.scheduler.core.Core.java
@Override protected String doInBackground() throws Exception { // new SplashWindow("E:\\Documentos\\NetBeansProjects\\documentos.scheduler.core\\src\\main\\java\\avoking\\com\\documentos\\scheduler\\startup\\SplashScreen reducida.png", null, this); setProgress(0);/*w w w. j a v a 2 s.c o m*/ LOGGER.info("Construyendo sesin hibernate."); try { session = ddi.getSessionFactory().getCurrentSession(); } catch (HibernateException ex) { LOGGER.debug("Could not retrieve pre-bound Hibernate session", ex); } setProgress(3); if (session == null) { session = ddi.getSessionFactory().openSession(); session.setFlushMode(FlushMode.MANUAL); } LOGGER.info("Iniciando exploracin..."); cantDocs = 0; Files.walk(Paths.get(pathDoc)).forEach(filePath -> { if (Files.isRegularFile(filePath)) { File f = filePath.toFile(); if (!f.getName().contains("~$")) if (filtro.accept(f)) cantDocs++; } }); LOGGER.debug("Cantidad de archivos a procesar: " + cantDocs); Files.walk(Paths.get(pathDoc)).forEach(filePath -> { if (Files.isRegularFile(filePath)) { File f = filePath.toFile(); if (!f.getName().contains("~$")) if (filtro.accept(f)) { if (!f.isDirectory()) { ca++; // LOGGER.info("Procesando documento: " + f.getName() + " " + ca + " %" + (((ca*97)/cantDocs) + 3) ); setProgress(Math.min(((ca * 97) / cantDocs) + 3, 100)); // try { // Thread.sleep(500); // } catch (InterruptedException ex) { // java.util.logging.Logger.getLogger(Core.class.getName()).log(Level.SEVERE, null, ex); // } procesar(f.getAbsolutePath()); } } // else { // LOGGER.warn("Archivo denegado: " + f.getName()); // } } }); setProgress(100); LOGGER.debug("Terminado"); return err; }
From source file:beans.TransacaoSistemaBiblioteca.java
public void iniciar() { sessaoHibernate = HibernateUtil.getSessionFactory().openSession(); sessaoHibernate.setFlushMode(FlushMode.MANUAL); }
From source file:br.gov.jfrj.siga.hibernate.ExDao.java
License:Open Source License
public void indexarTudo(Aguarde aguarde) throws Exception { System.out.println("Indexando documentos..."); long inicio = new Date().getTime(); try {/* ww w .j a v a2s. c o m*/ FullTextSession fullTextSession = Search.getFullTextSession(getSessao()); Transaction deleteTx = fullTextSession.beginTransaction(); fullTextSession.purgeAll(ExDocumento.class); deleteTx.commit(); fullTextSession.clear(); getSessao().clear(); } catch (Throwable t) { // No havia documentos a excluir } final Criteria crit = getSessao().createCriteria(ExDocumento.class); int index = 0; FullTextSession fullTextSession = Search.getFullTextSession(getSessao()); fullTextSession.setFlushMode(FlushMode.MANUAL); fullTextSession.setCacheMode(CacheMode.IGNORE); crit.setMaxResults(30); crit.addOrder(Order.desc("idDoc")); List<ExDocumento> list; do { crit.setFirstResult(index); list = crit.list(); Transaction tx = fullTextSession.beginTransaction(); for (ExDocumento doc : list) { index++; // if (aguarde != null) // aguarde.setMensagem(String.valueOf(index) // + " documentos j indexados."); if (doc.isIndexavel()) fullTextSession.index(doc); if (index % 100 == 0) { //System.gc(); // fullTextSession.flush(); // fullTextSession.clear(); } } tx.commit(); fullTextSession.clear(); getSessao().clear(); System.out.print(String.valueOf(index) + " documentos j indexados. -- -- "); } while (list.size() > 0); //System.gc(); // fullTextSession.close(); System.out.println("Durao da indexao de documentos: " + (new Date().getTime() - inicio)); if (aguarde != null) aguarde.setMensagem(String.valueOf(index)); }
From source file:ch.systemsx.cisd.openbis.generic.server.dataaccess.db.search.DefaultFullTextIndexer.java
License:Apache License
public final <T> void doFullTextIndex(final Session hibernateSession, final Class<T> clazz) throws DataAccessException { operationLog.info(String.format("Indexing '%s'...", clazz.getSimpleName())); final FullTextSession fullTextSession = Search.getFullTextSession(hibernateSession); fullTextSession.setFlushMode(FlushMode.MANUAL); fullTextSession.setCacheMode(CacheMode.IGNORE); // we index entities in batches loading them in groups restricted by id: // [ ids[index], ids[min(index+batchSize, maxIndex))] ) final Transaction transaction = hibernateSession.beginTransaction(); final List<Long> ids = getAllIds(fullTextSession, clazz); final int idsSize = ids.size(); operationLog.info(String.format("... got %d '%s' ids...", idsSize, clazz.getSimpleName())); int index = 0; final int maxIndex = idsSize - 1; // need to increment last id because we use 'lt' condition if (maxIndex > -1) { ids.set(maxIndex, ids.get(maxIndex) + 1); }//from w ww. ja v a 2s . c o m while (index < maxIndex) { final int nextIndex = getNextIndex(index, maxIndex); final long minId = ids.get(index); final long maxId = ids.get(nextIndex); final List<?> results = createCriteriaWithRestrictedId(fullTextSession, clazz, minId, maxId).list(); for (Object object : results) { indexEntity(hibernateSession, fullTextSession, object); index++; } operationLog.info(String.format("%d '%s' have been indexed...", index, clazz.getSimpleName())); fullTextSession.flushToIndexes(); hibernateSession.clear(); } fullTextSession.getSearchFactory().optimize(clazz); transaction.commit(); operationLog.info( String.format("'%s' index complete. %d entities have been indexed.", clazz.getSimpleName(), index)); }
From source file:com.abiquo.abiserver.persistence.hibernate.HibernateDAOFactory.java
License:Open Source License
@Override public void beginConnection(final boolean readOnly) { if (readOnly) { getSessionFactory().getCurrentSession().setFlushMode(FlushMode.MANUAL); } else {/*w w w. java 2 s . c o m*/ getSessionFactory().getCurrentSession().setFlushMode(FlushMode.AUTO); } getSessionFactory().getCurrentSession().beginTransaction(); }