List of usage examples for org.hibernate CacheMode GET
CacheMode GET
To view the source code for org.hibernate CacheMode GET.
Click Source Link
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();/*from www. j a v a2 s . c om*/ 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 . j a v a 2 s .c om 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:br.mdarte.exemplo.academico.cd.CursoDAO.java
public List<AbstractEntity> insert(AbstractEntity obj) throws DAOException { List<AbstractEntity> lista = new ArrayList<AbstractEntity>(); try {//w w w. jav a 2 s .co m Session session = currentSession(); session.setCacheMode(CacheMode.GET); session.save(obj); session.flush(); lista.add(obj); return lista; } catch (HibernateException e) { throw new DAOException(e); } }
From source file:br.mdarte.exemplo.academico.cd.CursoDAO.java
public List<AbstractEntity> insertOrUpdate(AbstractEntity obj) throws DAOException { List<AbstractEntity> lista = new ArrayList<AbstractEntity>(); try {/* w w w.j a va2 s . c o m*/ Session session = currentSession(); session.setCacheMode(CacheMode.GET); session.saveOrUpdate(obj); session.flush(); lista.add(obj); return lista; } catch (HibernateException e) { throw new DAOException(e); } }
From source file:br.mdarte.exemplo.academico.cd.CursoDAO.java
public List<AbstractEntity> update(AbstractEntity obj) throws DAOException { List<AbstractEntity> lista = new ArrayList<AbstractEntity>(); try {/*from www . java2 s. c o m*/ Session session = currentSession(); session.setCacheMode(CacheMode.GET); session.update(obj); session.flush(); lista.add(obj); return lista; } catch (HibernateException e) { throw new DAOException(e); } }
From source file:com.github.jmnarloch.hstreams.internal.QueryDelegateTest.java
License:Apache License
@Test public void testSetCacheMode() throws Exception { // given/*from ww w .j ava 2s .c om*/ final CacheMode cacheMode = CacheMode.GET; // then verifyMethodCall(q -> q.setCacheMode(cacheMode)); }
From source file:com.github.jmnarloch.hstreams.internal.SessionDelegateTest.java
License:Apache License
@Test public void testSetCacheMode() throws Exception { // given//from w w w . j a v a 2 s.co m final CacheMode cacheMode = CacheMode.GET; // then verifyMethodCall(s -> s.setCacheMode(cacheMode)); }
From source file:com.googlecode.osde.internal.shindig.AppDataService.java
License:Apache License
public Map<String, String> getApplicationDataMap(Person person, ApplicationImpl application) { Query query = session.createQuery( "select a from ApplicationDataMapImpl a where a.person = :person and a.application = :application"); query.setCacheMode(CacheMode.GET); query.setParameter("person", person); query.setParameter("application", application); ApplicationDataMapImpl applicationDataMap = (ApplicationDataMapImpl) query.uniqueResult(); if (applicationDataMap != null) { Map<String, String> result = new HashMap<String, String>(); result.putAll(applicationDataMap.getDataMap()); session.evict(applicationDataMap); return result; } else {// w ww .j a va 2 s . c om return null; } }
From source file:com.googlecode.osde.internal.shindig.AppDataService.java
License:Apache License
public void removeApplicationData(Person person, ApplicationImpl application, String key) { Transaction tx = session.beginTransaction(); Query query = session.createQuery( "select a from ApplicationDataMapImpl a where a.person = :person and a.application = :application"); query.setCacheMode(CacheMode.GET); query.setParameter("person", person); query.setParameter("application", application); ApplicationDataMapImpl applicationDataMap = (ApplicationDataMapImpl) query.uniqueResult(); if (applicationDataMap != null) { Map<String, String> dataMap = applicationDataMap.getDataMap(); dataMap.remove(key);/*from w w w.jav a 2 s .co m*/ session.update(applicationDataMap); } tx.commit(); }
From source file:com.googlecode.osde.internal.shindig.AppDataService.java
License:Apache License
public void addApplicationData(Person person, ApplicationImpl application, String key, String value) { Transaction tx = session.beginTransaction(); Query query = session.createQuery( "select a from ApplicationDataMapImpl a where a.person = :person and a.application = :application"); query.setCacheMode(CacheMode.GET); query.setParameter("person", person); query.setParameter("application", application); ApplicationDataMapImpl applicationDataMap = (ApplicationDataMapImpl) query.uniqueResult(); if (applicationDataMap == null) { applicationDataMap = new ApplicationDataMapImpl(); applicationDataMap.setPerson(person); applicationDataMap.setApplication(application); }/* www . ja v a 2s. c o m*/ Map<String, String> dataMap = applicationDataMap.getDataMap(); dataMap.put(key, value); session.saveOrUpdate(applicationDataMap); tx.commit(); }