List of usage examples for org.hibernate LockMode NONE
LockMode NONE
To view the source code for org.hibernate LockMode NONE.
Click Source Link
From source file:org.webical.dao.hibernateImpl.SettingsDaoHibernateImpl.java
License:Open Source License
@Transaction(readOnly = false) public void removeSettings(Settings settings) throws DaoException { if (settings == null) { return;//from w ww . ja v a2 s.c o m } try { getSession().buildLockRequest(new LockOptions(LockMode.NONE)).lock(settings); delete(settings); } catch (Exception exception) { log.error("Could not delete settings: " + settings, exception); throw new DaoException("Could not delete settings: " + settings, exception); } }
From source file:org.webical.dao.hibernateImpl.UserDaoHibernateImpl.java
License:Open Source License
@Transaction(readOnly = false) public void removeUser(User user) throws DaoException { try {//from www.j a v a 2s . c o m log.info("removeUser " + user.getUserId()); getSession().buildLockRequest(new LockOptions(LockMode.NONE)).lock(user); //Cascade calendars List<Calendar> calendars = calendarDao.getCalendars(user); if (calendars != null && calendars.size() > 0) { for (Calendar calendar : calendars) { calendarDao.removeCalendar(calendar); } } //Remove the user delete(user); } catch (Exception e) { log.error(e, e); throw new DaoException("Could not delete user", e); } }
From source file:owldb.util.OWLDBEventListener.java
License:Open Source License
/** * Reassociate an Object to the Session provided. * //from w ww . j av a2s. c om * @param source The session implementor source * @param object Worked object * @param result The loaded object * @param status The Hibernate status */ private void reassociateObject(final SessionImplementor source, final Object object, final Object result, final Status status) { final Serializable id = result instanceof OWLObject ? this.getID(source, (OWLObject) result) : source.getContextEntityIdentifier(result); if (id == null) return; final EntityPersister persister = source.getEntityPersister(null, object); final EntityMode entityMode = source.getEntityMode(); final EntityKey key = new EntityKey(id, persister, entityMode); // Get a snapshot final Type[] types = persister.getPropertyTypes(); final Object[] resultValues = persister.getPropertyValues(result, entityMode); final Object[] values = persister.getPropertyValues(object, entityMode); if (persister.hasCollections()) { for (int i = 0; i < types.length; i++) { if (!types[i].isCollectionType()) continue; if (values[i] instanceof Collection<?>) { final Collection<?> unsavedCol = (Collection<?>) values[i]; final CollectionType collectionType = (CollectionType) types[i]; final CollectionPersister colPersister = source.getFactory() .getCollectionPersister(collectionType.getRole()); final PersistenceContext persistenceContext = source.getPersistenceContext(); final PersistentCollection persistentCollection = collectionType.wrap(source, unsavedCol); final PersistentCollection resultCol = (PersistentCollection) resultValues[i]; final Serializable currentKey = resultCol.getKey(); persistenceContext.addInitializedCollection(colPersister, persistentCollection, currentKey); values[i] = persistentCollection; } persister.setPropertyValues(object, values, entityMode); } } TypeHelper.deepCopy(values, types, persister.getPropertyUpdateability(), values, source); final Object version = Versioning.getVersion(values, persister); // lazyPropertiesAreUnfetched: Will be ignored, using the existing Entry // instead source.getPersistenceContext().addEntity(object, status, values, key, version, LockMode.NONE, true, persister, false, true); persister.afterReassociate(object, source); }
From source file:uk.ac.ucl.chime.db.ArchetypeDataDAO.java
License:Apache License
public void attachClean(ArchetypeData instance) { log.debug("attaching clean ArchetypeData instance"); try {// w ww .j av a 2 s . c o m getSession().lock(instance, LockMode.NONE); log.debug("attach successful"); } catch (RuntimeException re) { log.error("attach failed", re); throw re; } }