List of usage examples for org.springframework.transaction.annotation Isolation REPEATABLE_READ
Isolation REPEATABLE_READ
To view the source code for org.springframework.transaction.annotation Isolation REPEATABLE_READ.
Click Source Link
From source file:org.projectforge.core.BaseDao.java
/** * @param obj// w ww. j av a2 s. co m * @throws AccessException * @return true, if modifications were done, false if no modification detected. * @see #internalUpdate(ExtendedBaseDO, boolean) */ @Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, isolation = Isolation.REPEATABLE_READ) public ModificationStatus update(final O obj) throws AccessException { Validate.notNull(obj); if (obj.getId() == null) { final String msg = "Could not update object unless id is not given:" + obj.toString(); log.error(msg); throw new RuntimeException(msg); } return internalUpdate(obj, true); }
From source file:org.projectforge.core.BaseDao.java
/** * This method is for internal use e. g. for updating objects without check access. * @param obj/*from w ww. j av a2 s .co m*/ * @return true, if modifications were done, false if no modification detected. * @see #internalUpdate(ExtendedBaseDO, boolean) */ @Transactional(readOnly = false, propagation = Propagation.REQUIRED, isolation = Isolation.REPEATABLE_READ) public ModificationStatus internalUpdate(final O obj) { return internalUpdate(obj, false); }
From source file:org.projectforge.core.BaseDao.java
/** * This method is for internal use e. g. for updating objects without check access.<br/> * Please note: update ignores the field deleted. Use markAsDeleted, delete and undelete methods instead. * @param obj/* www .j a va 2 s .c o m*/ * @param checkAccess If false, any access check will be ignored. * @return true, if modifications were done, false if no modification detected. */ @Transactional(readOnly = false, propagation = Propagation.REQUIRED, isolation = Isolation.REPEATABLE_READ) public ModificationStatus internalUpdate(final O obj, final boolean checkAccess) { onSaveOrModify(obj); if (checkAccess == true) { accessChecker.checkRestrictedOrDemoUser(); } final O dbObj = getHibernateTemplate().load(clazz, obj.getId(), LockMode.PESSIMISTIC_WRITE); if (checkAccess == true) { checkLoggedInUserUpdateAccess(obj, dbObj); } onChange(obj, dbObj); final O dbObjBackup; if (supportAfterUpdate == true) { dbObjBackup = getBackupObject(dbObj); } else { dbObjBackup = null; } final boolean wantsReindexAllDependentObjects = wantsReindexAllDependentObjects(obj, dbObj); // Copy all values of modified user to database object, ignore field 'deleted'. final ModificationStatus result = copyValues(obj, dbObj, "deleted"); if (result != ModificationStatus.NONE) { dbObj.setLastUpdate(); log.info("Object updated: " + dbObj.toString()); } else { log.info("No modifications detected (no update needed): " + dbObj.toString()); } prepareHibernateSearch(obj, OperationType.UPDATE); final Session session = getHibernateTemplate().getSessionFactory().getCurrentSession(); session.flush(); Search.getFullTextSession(session).flushToIndexes(); afterSaveOrModify(obj); if (supportAfterUpdate == true) { afterUpdate(obj, dbObjBackup); } else { afterUpdate(obj, null); } if (wantsReindexAllDependentObjects == true) { reindexDependentObjects(obj); } return result; }
From source file:org.projectforge.core.BaseDao.java
/** * Object will be marked as deleted (boolean flag), therefore undelete is always possible without any loss of data. * @param obj//from w w w .j a v a 2 s. c o m */ @Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, isolation = Isolation.REPEATABLE_READ) public void markAsDeleted(final O obj) throws AccessException { Validate.notNull(obj); if (obj.getId() == null) { final String msg = "Could not delete object unless id is not given:" + obj.toString(); log.error(msg); throw new RuntimeException(msg); } final O dbObj = getHibernateTemplate().load(clazz, obj.getId(), LockMode.PESSIMISTIC_WRITE); checkLoggedInUserDeleteAccess(obj, dbObj); accessChecker.checkRestrictedOrDemoUser(); internalMarkAsDeleted(obj); }
From source file:org.projectforge.core.BaseDao.java
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, isolation = Isolation.REPEATABLE_READ) public void internalMarkAsDeleted(final O obj) { if (obj instanceof Historizable == false) { log.error(/*from w w w . ja v a2s. c o m*/ "Object is not historizable. Therefore marking as deleted is not supported. Please use delete instead."); throw new InternalErrorException(); } onDelete(obj); final O dbObj = getHibernateTemplate().load(clazz, obj.getId(), LockMode.PESSIMISTIC_WRITE); onSaveOrModify(obj); copyValues(obj, dbObj, "deleted"); // If user has made additional changes. dbObj.setDeleted(true); dbObj.setLastUpdate(); final Session session = getHibernateTemplate().getSessionFactory().getCurrentSession(); session.flush(); Search.getFullTextSession(session).flushToIndexes(); afterSaveOrModify(obj); afterDelete(obj); getSession().flush(); log.info("Object marked as deleted: " + dbObj.toString()); }
From source file:org.projectforge.core.BaseDao.java
/** * Object will be deleted finally out of the data base. * @param obj// ww w. j a v a2 s .c o m */ @Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, isolation = Isolation.REPEATABLE_READ) public void delete(final O obj) throws AccessException { Validate.notNull(obj); if (obj instanceof Historizable) { final String msg = EXCEPTION_HISTORIZABLE_NOTDELETABLE + obj.toString(); log.error(msg); throw new RuntimeException(msg); } if (obj.getId() == null) { final String msg = "Could not destroy object unless id is not given: " + obj.toString(); log.error(msg); throw new RuntimeException(msg); } accessChecker.checkRestrictedOrDemoUser(); onDelete(obj); final O dbObj = getHibernateTemplate().load(clazz, obj.getId(), LockMode.PESSIMISTIC_WRITE); checkLoggedInUserDeleteAccess(obj, dbObj); getHibernateTemplate().delete(dbObj); log.info("Object deleted: " + obj.toString()); afterSaveOrModify(obj); afterDelete(obj); }
From source file:org.projectforge.core.BaseDao.java
/** * Object will be marked as deleted (booelan flag), therefore undelete is always possible without any loss of data. * @param obj//from ww w.ja v a2 s . c o m */ @Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, isolation = Isolation.REPEATABLE_READ) public void undelete(final O obj) throws AccessException { Validate.notNull(obj); if (obj.getId() == null) { final String msg = "Could not undelete object unless id is not given:" + obj.toString(); log.error(msg); throw new RuntimeException(msg); } checkLoggedInUserInsertAccess(obj); accessChecker.checkRestrictedOrDemoUser(); internalUndelete(obj); }
From source file:org.projectforge.core.BaseDao.java
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, isolation = Isolation.REPEATABLE_READ) public void internalUndelete(final O obj) { final O dbObj = getHibernateTemplate().load(clazz, obj.getId(), LockMode.PESSIMISTIC_WRITE); onSaveOrModify(obj);//from w w w . j a v a 2 s . c om copyValues(obj, dbObj, "deleted"); // If user has made additional changes. dbObj.setDeleted(false); obj.setDeleted(false); dbObj.setLastUpdate(); obj.setLastUpdate(dbObj.getLastUpdate()); log.info("Object undeleted: " + dbObj.toString()); final Session session = getHibernateTemplate().getSessionFactory().getCurrentSession(); session.flush(); Search.getFullTextSession(session).flushToIndexes(); afterSaveOrModify(obj); afterUndelete(obj); }
From source file:org.projectforge.core.BaseDao.java
/** * Re-index all dependent objects manually (hibernate search). Hibernate doesn't re-index these objects, does it? * @param obj/*from w ww . j a v a2 s . c o m*/ */ @Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, isolation = Isolation.REPEATABLE_READ) public void reindexDependentObjects(final O obj) { HibernateSearchDependentObjectsReindexer.getSingleton().reindexDependents(getHibernateTemplate(), obj); }
From source file:org.projectforge.core.ConfigurationDao.java
/** * Checks and creates missing data base entries. Updates also out-dated descriptions. *//*from w ww.jav a2 s.c o m*/ @Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, isolation = Isolation.REPEATABLE_READ) public void checkAndUpdateDatabaseEntries() { final List<ConfigurationDO> list = internalLoadAll(); final Set<String> params = new HashSet<String>(); for (final ConfigurationParam param : ConfigurationParam.values()) { checkAndUpdateDatabaseEntry(param, list, params); } for (final ConfigurationDO entry : list) { if (params.contains(entry.getParameter()) == false) { log.error("Unknown configuration entry. Mark as deleted: " + entry.getParameter()); internalMarkAsDeleted(entry); } } }