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.adsapient.shared.dao.HibernateEntityDao.java
License:Open Source License
public Integer executeQueryInsert(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.createSQLQuery(queryName); Integer res = query.executeUpdate(); tx.commit();/* w ww.ja v a 2s.c o m*/ return res; } }); }
From source file:com.astonish.dropwizard.routing.hibernate.RoutingUnitOfWorkApplicationListenerTest.java
License:Apache License
@Test public void configuresTheSessionsCacheMode() throws Exception { prepareAppEvent("methodWithCacheModeIgnoreAnnotation"); execute();/*from www. j a v a2 s . c om*/ verify(session).setCacheMode(CacheMode.IGNORE); }
From source file:com.astonish.dropwizard.routing.hibernate.RoutingUnitOfWorkRequestDispatcherTest.java
License:Apache License
@Test public void configuresTheSessionsCacheMode() throws Exception { when(unitOfWork.cacheMode()).thenReturn(CacheMode.IGNORE); dispatcher.dispatch(resource, context); verify(session).setCacheMode(CacheMode.IGNORE); }
From source file:com.booleanworks.kryptopterus.application.WebAppBootstrapper.java
License:Apache License
public void setupMandatoryData() { System.out.println("com.booleanworks.kryptopterus.application.WebAppBootstrapper.setupMandatoryData()"); System.out.println("Bootstrap-CP0005"); MainHibernateUtil mhu = MainHibernateUtil.getInstance(); Session session = mhu.getNewSession(FlushMode.ALWAYS, CacheMode.IGNORE); System.out.println("Bootstrap-CP0010"); AppUser adminUser = AppUser.QuickCreateNewAppUser("admin", "4dm1n", "mickael.lecabellec@booleaworks.com", session);//from w w w.j a v a 2s . c om AppUser testUser = AppUser.QuickCreateNewAppUser("test001", "test001", "mickael.lecabellec@booleaworks.com", session); System.out.println("Bootstrap-CP0020"); AppUserGroup adminRole = AppUserGroup.findOrCreateAppUserGroup("ROLE_ADMIN", session); AppUserGroup userRole = AppUserGroup.findOrCreateAppUserGroup("ROLE_USER", session); AppUserGroup testUserRole = AppUserGroup.findOrCreateAppUserGroup("ROLE_TESTUSER", session); AppUserGroup anonymousRole = AppUserGroup.findOrCreateAppUserGroup("ROLE_ANONYMOUS", session); System.out.println("Bootstrap-CP0030"); AppUserGroupMembership.quickAddMember(adminRole, adminUser, session); AppUserGroupMembership.quickAddMember(userRole, adminUser, session); AppUserGroupMembership.quickAddMember(testUserRole, adminUser, session); AppUserGroupMembership.quickAddMember(userRole, testUser, session); AppUserGroupMembership.quickAddMember(testUserRole, testUser, session); System.out.println("Bootstrap-CP0040"); AppActivityStatus.findOrCreate("Default status for not started activities", "NOT_STARTED", session); AppActivityStatus.findOrCreate("Default status for started activities", "STARTED", session); AppActivityStatus.findOrCreate("Default status for finished activities", "FINISHED", session); AppActivityStatusTransition.findOrCreate("NOT_STARTED", "STARTED", "ROLE_USER", session); AppActivityStatusTransition.findOrCreate("STARTED", "FINISHED", "ROLE_USER", session); mhu.closeSession(session); }
From source file:com.booleanworks.kryptopterus.application.WebAppBootstrapper.java
License:Apache License
public void setupTestData() { System.out.println("com.booleanworks.kryptopterus.application.WebAppBootstrapper.setupTestData()"); System.out.println("Bootstrap-CP0041"); MainHibernateUtil mhu = MainHibernateUtil.getInstance(); Session session = mhu.getNewSession(FlushMode.ALWAYS, CacheMode.IGNORE); Calendar c = Calendar.getInstance(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss"); System.out.println("Bootstrap-CP0050"); AppActivityStatus.findOrCreate("New activity from app bootstrap", "TESTSTATUS_NEW", session); AppActivityStatus.findOrCreate("Finished (bootstrapactivity", "TESTSTATUS_FINISHED", session); AppActivityStatusTransition.findOrCreate("TESTSTATUS_NEW", "TESTSTATUS_FINISHED", "ROLE_ADMIN", session); System.out.println("Bootstrap-CP0060"); ArrayList<AppActivity> testActivities = new ArrayList<>(); AppUserGroup testUserRole = AppUserGroup.findOrCreateAppUserGroup("ROLE_TESTUSER", session); AppUser adminUser = AppUser.findUserOrNull("admin", session); if (adminUser == null) { System.err.println("WARNING: mandatory data missing... rebuilding"); this.setupMandatoryData(); }// www . j av a 2 s.c o m for (int ct1 = 0; ct1 < 30; ct1++) { Transaction transaction = mhu.beginTransaction(session, false); AppActivity newTestActivity = AppActivity.findOrCreateWithBusinessIdentifier( "Test activity " + simpleDateFormat.format(c.getTime()), "TESTDATA-" + ct1, "TESTSTATUS_NEW", session); newTestActivity.setAuthorizedForView(testUserRole); newTestActivity.setAuthorizedForModification(testUserRole); newTestActivity.setAuthorizedForDeletion(testUserRole); newTestActivity.setCreator(adminUser); newTestActivity.setLastEditor(adminUser); newTestActivity.setCreationDate(new Date()); newTestActivity.setModificationDate(new Date()); newTestActivity.setPlannedStart(new Date()); newTestActivity.setPlannedEnd(new Date()); mhu.saveOrUpdate(newTestActivity, session); newTestActivity.addProperty(new AppProperty("MARKER", "TESTDATA"), session); mhu.saveOrUpdate(newTestActivity, session); testActivities.add(newTestActivity); mhu.commitTransaction(session, transaction); } Random random = new Random(); for (int ct2 = 0; ct2 < 10; ct2++) { Transaction transaction = mhu.beginTransaction(session, false); AppActivity a1 = testActivities.get(random.nextInt(testActivities.size())); AppActivity a2 = testActivities.get(random.nextInt(testActivities.size())); AppActivityRelation aar = new AppActivityRelation(); aar.setAuthorizedForView(testUserRole); aar.setAuthorizedForModification(testUserRole); aar.setAuthorizedForDeletion(testUserRole); aar.setCreator(adminUser); aar.setLastEditor(adminUser); aar.setCreationDate(new Date()); aar.setModificationDate(new Date()); aar.setDisplayName("TESTDATA-TRANSITION-" + simpleDateFormat.format(c.getTime()) + "-" + ct2); mhu.saveOrUpdate(aar, session); aar.link(a1, a2, session); aar.addProperty(new AppProperty("MARKER", "TESTDATA"), session); mhu.saveOrUpdate(aar, session); mhu.commitTransaction(session, transaction); } mhu.closeSession(session); }
From source file:com.booleanworks.kryptopterus.entities.AppActivityRelation.java
License:Apache License
@Deprecated public void link(AppActivity first, AppActivity second) { Session session = MainHibernateUtil.getInstance().getNewSession(FlushMode.ALWAYS, CacheMode.IGNORE); this.link(first, second, session); session.flush();// www . jav a 2 s . c om session.close(); }
From source file:com.creative.dao.repository.GenericBatchDaoImpl.java
License:Apache License
@Override public int executeUpdate(Query query) { Session session = sessionFactory.getCurrentSession(); session.setCacheMode(CacheMode.IGNORE); session.setFlushMode(FlushMode.MANUAL); int rows = query.executeUpdate(); session.flush();//from www.jav a2 s . c om logger.info("Updated rows " + rows + " for " + query.getQueryString()); return rows; }
From source file:com.creative.dao.repository.GenericBatchDaoImpl.java
License:Apache License
private <T> int executeBatch(BatchType batchType, List<T> list) { Session session = sessionFactory.getCurrentSession(); session.setCacheMode(CacheMode.IGNORE); session.setFlushMode(FlushMode.MANUAL); logger.info("Executing Batch of size :" + list.size() + " given batch size is:" + batchSize); for (int i = 0; i < list.size(); i++) { switch (batchType) { case BATCH_INSERT: session.save(list.get(i));// w w w.j a v a2s . co m break; case BATCH_DELETE: session.delete(list.get(i)); break; case BATCH_INSERT_OR_UPDATE: session.saveOrUpdate(list.get(i)); default: // nothing; } if (i > 0 && i % batchSize == 0) { logger.info("Flushing and clearing the cache" + " after row number :" + i); session.flush(); session.clear(); } } session.flush(); return list.size(); }
From source file:com.creative.dao.repository.GenericBatchDaoImplTest.java
License:Apache License
public void verifySession() { verify(hibernateParam.session).setCacheMode(CacheMode.IGNORE); verify(hibernateParam.session).setFlushMode(FlushMode.MANUAL); }
From source file:com.douchebag.server.hibernate.HibernateHelper.java
License:Apache License
public HibernateHelper() throws Exception { try {//from w ww .j a v a 2 s . c o m mSession = HibernateUtil.getSession(); mSession.setCacheMode(CacheMode.IGNORE); } catch (Exception e) { throw e; } }