List of usage examples for org.hibernate Session setFlushMode
@Deprecated
void setFlushMode(FlushMode flushMode);
From source file:com.gisgraphy.domain.repository.GenericDao.java
License:Open Source License
public void setFlushMode(final FlushMode flushMode) { Assert.notNull(flushMode);//w ww. j a v a 2s. c o m this.getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) { session.setFlushMode(flushMode); return null; } }); }
From source file:com.globalsight.persistence.hibernate.HibernateUtil.java
License:Apache License
/** * Gets a session from ThreadLocal.//from w w w . j a v a2s.c o m * * @return session */ public static Session getSession() throws HibernateException { Session session = sessionContext.get(); if (session == null || !session.isOpen()) { session = sessionFactory.openSession(); session.setFlushMode(FlushMode.COMMIT); sessionContext.set(session); s_logger.debug("Hibernate open session"); } return session; }
From source file:com.jeroensteenbeeke.hyperion.data.HibernateDAO.java
License:Open Source License
/** * @return The Session for this factory/* w ww.j a v a 2 s . c o m*/ */ public Session getSession() { Session session = sessionFactory.getCurrentSession(); session.setFlushMode(FlushMode.COMMIT); log.info("DAO using session " + session.hashCode()); return session; }
From source file:com.lecaddyfute.model.dao.AbstractHibernateDAO.java
protected final Session getCurrentSession() { Session s = this.sessionFactory.getCurrentSession(); s.setFlushMode(FlushMode.COMMIT); return s;/*from www. j a va 2s. co m*/ }
From source file:com.maydesk.base.util.CledaConnector.java
License:Mozilla Public License
public Session createSession() { Session session = sessionFactory.openSession(); session.setFlushMode(FlushMode.COMMIT); session.beginTransaction();/*from ww w .j a va2s . c o m*/ return session; }
From source file:com.mobileman.filter.OpenSessionFilter.java
License:Apache License
/** * Get a Session for the SessionFactory that this filter uses. Note that * this just applies in single session mode! * <p>/*from w w w . java 2 s . c o m*/ * The default implementation delegates to the * <code>SessionFactoryUtils.getSession</code> method and sets the * <code>Session</code>'s flush mode to "MANUAL". * <p> * Can be overridden in subclasses for creating a Session with a custom * entity interceptor or JDBC exception translator. * * @param sessionFactory * the SessionFactory that this filter uses * @return the Session to use * @throws DataAccessResourceFailureException * if the Session could not be created * @see org.springframework.orm.hibernate3.SessionFactoryUtils#getSession(SessionFactory, * boolean) * @see org.hibernate.FlushMode#MANUAL */ static protected Session getSession(SessionFactory sessionFactory) throws DataAccessResourceFailureException { Session session = SessionFactoryUtils.getSession(sessionFactory, true); FlushMode flushMode = getFlushMode(); if (flushMode != null) { session.setFlushMode(flushMode); } return session; }
From source file:com.mtech.easyexchange.SessionFactoryProvider.java
License:Open Source License
public static Session openSession() { Session session = sessionFactory.openSession(); session.setFlushMode(FlushMode.MANUAL); ManagedSessionContext.bind(session); return session; }
From source file:com.pacs.utils.HibernateUtilsAnnot.java
public static Session currentSession() { Session s = (Session) session.get(); // Open a new Session, if this Thread has none yet if ((s == null) || (!s.isOpen())) { if (localInterceptor.get() == null) { // localInterceptor.set(new AuditLogInterceptor()); s = sessionFactory.openSession((Interceptor) localInterceptor.get()); s.setFlushMode(FlushMode.COMMIT); } else {/*from w w w . j av a2 s .c o m*/ Interceptor interceptor = (Interceptor) localInterceptor.get(); s = sessionFactory.openSession(interceptor); s.setFlushMode(FlushMode.COMMIT); } session.set(s); } return s; }
From source file:com.peterphi.std.guice.hibernate.module.TransactionMethodInterceptor.java
License:Apache License
/** * Make the session (and the underlying {@link java.sql.Connection} read only * * @param session// www . j ava 2 s.c om */ private void makeReadOnly(final Session session) { session.setDefaultReadOnly(true); session.setFlushMode(FlushMode.MANUAL); // Make the Connection read only session.doWork(SetJDBCConnectionReadOnlyWork.READ_ONLY); }
From source file:com.rdsic.pcm.common.HibernateUtil.java
public static Session currentSession() { initSessionFactory("hibernate.cfg.xml"); Session s = (Session) session.get(); if ((s == null) || (!s.isConnected())) { s = sessionFactory.openSession(); s.setFlushMode(FlushMode.COMMIT); s.setCacheMode(CacheMode.IGNORE); session.set(s);/*from ww w .ja va 2 s . c om*/ } return s; }