Example usage for org.springframework.transaction.annotation Propagation REQUIRED

List of usage examples for org.springframework.transaction.annotation Propagation REQUIRED

Introduction

In this page you can find the example usage for org.springframework.transaction.annotation Propagation REQUIRED.

Prototype

Propagation REQUIRED

To view the source code for org.springframework.transaction.annotation Propagation REQUIRED.

Click Source Link

Document

Support a current transaction, create a new one if none exists.

Usage

From source file:org.openhie.openempi.service.KeyManagerService.java

/**
 * Generates a new key to the keystore.//from w  w  w .  j  a v  a  2 s  .c o  m
 * 
 * @return The added Key entity
 */
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public Key addKey() throws ApplicationException;

From source file:com.healthcit.cacure.dao.QuestionTableDao.java

@Transactional(propagation = Propagation.REQUIRED)
public void reorderQuestions(Long sourceQuestionId, Long targetQuestionId, boolean before) {

    Validate.notNull(sourceQuestionId);// www  . jav a  2s. co m
    Validate.notNull(targetQuestionId);

    if (sourceQuestionId.equals(targetQuestionId)) {
        return;
    }

    Query query = em.createQuery("SELECT ord, form.id FROM TableQuestion WHERE id = :id");

    Object[] result = (Object[]) query.setParameter("id", sourceQuestionId).getSingleResult();
    int sOrd = (Integer) result[0];
    long sFormId = (Long) result[1];

    result = (Object[]) query.setParameter("id", targetQuestionId).getSingleResult();
    int tOrd = (Integer) result[0];
    long tFormId = (Long) result[1];

    Validate.isTrue(sFormId == tFormId); //reorder only inside one form

    if (sOrd == tOrd || (before && sOrd == tOrd - 1) || (!before && sOrd == tOrd + 1)) {
        return;
    } else if (sOrd < tOrd) {
        em.createQuery("UPDATE TableQuestion SET ord = ord - 1 WHERE ord > :sOrd and ord "
                + (before ? "<" : "<=") + " :tOrd and form.id = :formId").setParameter("sOrd", sOrd)
                .setParameter("tOrd", tOrd).setParameter("formId", sFormId).executeUpdate();
        em.createQuery("UPDATE TableQuestion SET ord = :tOrd WHERE id = :qId")
                .setParameter("qId", sourceQuestionId).setParameter("tOrd", before ? tOrd - 1 : tOrd)
                .executeUpdate();
    } else if (sOrd > tOrd) {
        em.createQuery("UPDATE TableQuestion SET ord = ord + 1 WHERE ord < :sOrd and ord "
                + (before ? ">=" : ">") + " :tOrd and form.id = :formId").setParameter("sOrd", sOrd)
                .setParameter("tOrd", tOrd).setParameter("formId", sFormId).executeUpdate();
        em.createQuery("UPDATE TableQuestion SET ord = :tOrd WHERE id = :qId")
                .setParameter("qId", sourceQuestionId).setParameter("tOrd", before ? tOrd : tOrd + 1)
                .executeUpdate();
    }
}

From source file:dao.DAOToken.java

/**
 * //from w ww .j a v a 2  s .c o m
 * @param _token 
 */
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = exceptionsDAO.BorrarTokenException.class)
public void borrarToken(Token _token) {
    em.remove(em.merge(_token));
}

From source file:cs544.letmegiveexam.service.QuestionService.java

@Transactional(propagation = Propagation.REQUIRED)
public void deleteQuestion(Question question) {
    crudfasade.delete(question);
}

From source file:com.karriem.tp2.immutable_domain_model_assignment.Service.Crud.MedicalAidCrud.Impl.MedicalAidCrudServiceImpl.java

@Override
@Transactional(propagation = Propagation.REQUIRED)
public MedicalAid remove(MedicalAid entity) {

    return null;
}

From source file:org.fits.proweb.business.UserComponent.java

@Override
@Transactional(propagation = Propagation.REQUIRED)
public void delUser(String userLogin) {
    userRoleDao.delUserRole(userLogin);
    userDao.delUser(userLogin);
}

From source file:com.banda.truckmanagementmodel.services.crud.Impl.RefrigeratedContainerCrudServiceImpl.java

@Override
@Transactional(propagation = Propagation.REQUIRED)
public RefrigeratedContainer remove(RefrigeratedContainer entity) {
    return null;
}

From source file:cs544.wamp_blog_engine.service.impl.CategoryTagService.java

@Transactional(propagation = Propagation.REQUIRED)
@Override
public void addTag(Tag tag) {
    tagDAO.addTag(tag);
}

From source file:com.karriem.tp2.immutable_domain_model_assignment.Service.Crud.EmployeesCrud.Impl.NursesCrudServiceImpl.java

@Override
@Transactional(propagation = Propagation.REQUIRED)
public NursesPersonal remove(NursesPersonal entity) {

    return null;
}

From source file:com.karriem.tp2.immutable_domain_model_assignment.Service.Crud.PaymentMethodCrud.Impl.CreditCardCrudServiceImpl.java

@Override
@Transactional(propagation = Propagation.REQUIRED)
public CreditCard remove(CreditCard entity) {

    return null;
}