Example usage for org.hibernate LockMode NONE

List of usage examples for org.hibernate LockMode NONE

Introduction

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

Prototype

LockMode NONE

To view the source code for org.hibernate LockMode NONE.

Click Source Link

Document

No lock required.

Usage

From source file:gov.nih.nci.cabig.caaers.dao.report.ReportDao.java

License:BSD License

/**
 * This method will reassociate the domain object to hibernate session. With a lock mode none.
 * //w  w  w. j av a 2  s.c  om
 * @param report -
 *                the domain object instance that is to be reassociated
 */
@Override
@Transactional(propagation = Propagation.REQUIRED)
public void reassociate(Report report) {
    getHibernateTemplate().lock(report, LockMode.NONE);
}

From source file:gov.nih.nci.cabig.caaers.dao.report.ReportDefinitionDao.java

License:BSD License

/**
 * This method will reassociate the domain object to hibernate session. With a lock mode none.
 * //from   w  w  w  .  j a va  2  s.c  om
 * @param o -
 *                the domain object instance that is to be reassociated
 */
@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public void reassociate(ReportDefinition o) {
    getHibernateTemplate().lock(o, LockMode.NONE);
}

From source file:gov.nih.nci.cabig.caaers.dao.StudyDao.java

License:BSD License

/**
 * This utility method is used to lock the study. 
 * @param studyOrg/* w  w w  .  ja v a  2  s  .  com*/
 */
public void reassociateStudyOrganizations(List<StudyOrganization> studyOrgs) {
    for (StudyOrganization studyOrg : studyOrgs) {
        getHibernateTemplate().lock(studyOrg, LockMode.NONE);
    }

}

From source file:gov.nih.nci.cabig.caaers.dao.StudyParticipantAssignmentDao.java

License:BSD License

/**
 * This method will reassociate the domain object to hibernate session. With a lock mode none.
 * /* ww  w .  j a  va2  s.co  m*/
 * @param assignment -
 *                the domain object instance that is to be reassociated.
 */
@Override
public void reassociate(StudyParticipantAssignment assignment) {
    getHibernateTemplate().lock(assignment, LockMode.NONE);
}

From source file:gr.abiss.calipso.service.impl.UserServiceImpl.java

License:Open Source License

@Override
@Transactional(readOnly = false)/*  w  w  w  .j a  va 2 s  . c o m*/
public void expireResetPasswordTokens() {
    // get a hibernate session suitable for read-only access to large datasets
    StatelessSession session = ((Session) this.repository.getEntityManager().getDelegate()).getSessionFactory()
            .openStatelessSession();
    Date yesterday = DateUtils.addDays(new Date(), -1);

    // send email notifications for account confirmation tokens that expired
    org.hibernate.Query query = session.createQuery(
            "SELECT new gr.abiss.calipso.model.UserDTO(u.id, u.firstName, u.lastName,u.username, u.email, u.emailHash) FROM User u "
                    + "WHERE u.password IS NULL and u.resetPasswordTokenCreated IS NOT NULL and u.resetPasswordTokenCreated  < :yesterday");
    query.setParameter("yesterday", yesterday);
    query.setFetchSize(Integer.valueOf(1000));
    query.setReadOnly(true);
    query.setLockMode("a", LockMode.NONE);
    ScrollableResults results = query.scroll(ScrollMode.FORWARD_ONLY);
    while (results.next()) {
        UserDTO dto = (UserDTO) results.get(0);
        // TODO: send expiration email
        this.emailService.sendAccountConfirmationExpired(new User(dto));
    }
    results.close();
    session.close();

    // expire tokens, including password reset requests
    this.repository.expireResetPasswordTokens(yesterday);
}

From source file:grails.orm.HibernateCriteriaBuilder.java

License:Apache License

/**
 * Whether a pessimistic lock should be obtained.
 *
 * @param shouldLock True if it should// ww  w  . j  a  v a 2 s  .  c  o m
 */
public void lock(boolean shouldLock) {
    String lastAlias = getLastAlias();

    if (shouldLock) {
        if (lastAlias != null) {
            criteria.setLockMode(lastAlias, LockMode.PESSIMISTIC_WRITE);
        } else {
            criteria.setLockMode(LockMode.PESSIMISTIC_WRITE);
        }
    } else {
        if (lastAlias != null) {
            criteria.setLockMode(lastAlias, LockMode.NONE);
        } else {
            criteria.setLockMode(LockMode.NONE);
        }
    }
}

From source file:itensil.repository.hibernate.RepositoryEntity.java

License:Open Source License

/**
 * /*  w  w w  . j  a  v  a 2s  . c  o m*/
 * @param node
 * @throws AccessDeniedException
 * @throws NotFoundException
 * @throws LockException
 */
public void removeNode(NodeEntity node) throws AccessDeniedException, NotFoundException, LockException {

    User caller = SecurityAssociation.getUser();

    if (!hasPermission(caller, node, DefaultNodePermission.WRITE)) {
        throw new AccessDeniedException(node.getUri(), "write");
    }
    /*
    perhaps a lock check here? but this guy has managed to
    worked without (under light use) for 2 years
    */
    deepRemoveNode(node, node.getNodeId());
    Set parKids = node.getParentNode().getChildEntities();
    if (Hibernate.isInitialized(parKids)) {
        parKids.remove(node);
    }

    getManager().fireContentChangeEvent(node, null, ContentEvent.Type.REMOVE);

    Session session = HibernateUtil.getSession();
    session.flush();
    session.lock(node, LockMode.NONE);
    session.evict(node);
}

From source file:itensil.repository.RepositoryHelper.java

License:Open Source License

public static void releaseNode(RepositoryNode node) {
    HibernateUtil.getSession().lock(node, LockMode.NONE);
}

From source file:itensil.workflow.activities.state.ActivityStateStore.java

License:Open Source License

public void passivateToken(Activity token) throws StateException {
    Session sess = getSession();/*  ww w .  j a v  a  2  s  .  c o  m*/
    for (ActivityStepState state : token.getStates().values()) {
        if (state.getId() == null) {
            sess.save(state);
        } else if (state.isFlowDirty()) {
            sess.update(state);
        }
        state.setFlowDirty(false);
    }
    sess.lock(token, LockMode.NONE);
}

From source file:jedai.domain.security.AclClassHome.java

License:Open Source License

public void attachClean(AclClass instance) {
    log.debug("attaching clean AclClass instance");
    try {//from   www  .  j a va 2  s  .  co  m
        sessionFactory.getCurrentSession().lock(instance, LockMode.NONE);
        log.debug("attach successful");
    } catch (RuntimeException re) {
        log.error("attach failed", re);
        throw re;
    }
}