Example usage for org.hibernate LockOptions LockOptions

List of usage examples for org.hibernate LockOptions LockOptions

Introduction

In this page you can find the example usage for org.hibernate LockOptions LockOptions.

Prototype

public LockOptions(LockMode lockMode) 

Source Link

Document

Constructs a LockOptions with the given lock mode.

Usage

From source file:org.webical.dao.hibernateImpl.EventDaoWebDavHibernateBufferedImpl.java

License:Open Source License

@Transaction(readOnly = false)
public void removeAllEventsForCalendar(Calendar calendar) throws DaoException {
    if (calendar == null)
        return;// w w w  . j av  a  2s. co m

    if (log.isDebugEnabled()) {
        log.debug("Removing all events for calendar: " + calendar.getName());
    }
    try {
        getSession().buildLockRequest(new LockOptions(LockMode.NONE)).lock(calendar);
        removeAllEvents(getEventsForCalendar(calendar));
    } catch (Exception e) {
        log.error(e, e);
        throw new DaoException("Could not remove EventList", e);
    }
}

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;// ww  w . j a  v a 2  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  w  w w .j  a  v a2  s.c  om
        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:org.yes.cart.dao.impl.GenericDAOHibernateImpl.java

License:Apache License

/**
 * {@inheritDoc}//  ww  w. j  a v  a2  s  .com
 */
@SuppressWarnings("unchecked")
public List<T> findByNamedQueryForUpdate(final String namedQueryName, final int timeout,
        final Object... parameters) {
    Query query = sessionFactory.getCurrentSession().getNamedQuery(namedQueryName);
    LockOptions opts = new LockOptions(LockMode.PESSIMISTIC_WRITE);
    opts.setTimeOut(timeout);
    query.setLockOptions(opts);
    if (parameters != null) {
        setQueryParameters(query, parameters);
    }
    return query.list();
}