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

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

Introduction

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

Prototype

Propagation MANDATORY

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

Click Source Link

Document

Support a current transaction, throw an exception if none exists.

Usage

From source file:ru.org.linux.user.UserLogDao.java

@Transactional(rollbackFor = Exception.class, propagation = Propagation.MANDATORY)
public void logRegister(int userid, @Nonnull String ip) {
    jdbcTemplate.update(/*from   w w  w  .  j a va 2 s  . c  o  m*/
            "INSERT INTO user_log (userid, action_userid, action_date, action, info) VALUES (?,?,CURRENT_TIMESTAMP, ?::user_log_action, ?)",
            userid, userid, UserLogAction.REGISTER.toString(), ImmutableMap.of(OPTION_IP, ip));
}

From source file:com.epam.catgenome.dao.vcf.VcfFileDao.java

/**
 * Load sample metadata from the database for a given file ID.
 *
 * @param vcfFileId {@code long} file ID for which samples were saved.
 * @return {@code List<Sample>} of samples for given file ID.
 *//*  www  .  ja  va 2 s.c om*/
@Transactional(propagation = Propagation.MANDATORY)
public List<VcfSample> loadSamplesForFile(long vcfFileId) {
    return getJdbcTemplate().query(loadSamplesForFileQuery, SampleParameters.getVcfSampleMapper(), vcfFileId);
}

From source file:com.epam.catgenome.dao.BiologicalDataItemDao.java

@Transactional(propagation = Propagation.MANDATORY)
public List<BiologicalDataItem> loadFilesByNamesStrict(final List<String> names) {
    if (CollectionUtils.isEmpty(names)) {
        return Collections.emptyList();
    }/*from  w  w  w .  j  a  va2 s.c  o  m*/

    long listId = daoHelper.createTempStringList(names);

    List<BiologicalDataItem> items = getJdbcTemplate().query(loadBiologicalDataItemsByNamesStrictQuery,
            getRowMapper(), listId);

    daoHelper.clearTempStringList(listId);
    return items;
}

From source file:ru.org.linux.user.UserLogDao.java

@Transactional(rollbackFor = Exception.class, propagation = Propagation.MANDATORY)
public void setCorrector(@Nonnull User user, @Nonnull User moderator) {
    jdbcTemplate.update(/*from  ww w  . ja va2s  . co  m*/
            "INSERT INTO user_log (userid, action_userid, action_date, action, info) VALUES (?,?,CURRENT_TIMESTAMP, ?::user_log_action, ?)",
            user.getId(), moderator.getId(), UserLogAction.SET_CORRECTOR.toString(), ImmutableMap.of());
}

From source file:com.epam.catgenome.dao.reference.ReferenceGenomeDao.java

/**
 * Deletes a persisted {@code Reference} entity from the database by a specified ID
 * @param referenceId {@code Reference} ID to delete
 *///  w  w  w .  j a  v a2s . c o  m
@Transactional(propagation = Propagation.MANDATORY)
public void unregisterReferenceGenome(final Long referenceId) {
    getJdbcTemplate().update(deleteReferenceChromosomeQuery, referenceId);
    getJdbcTemplate().update(deleteReferenceQuery, referenceId);
}

From source file:com.epam.catgenome.dao.DaoHelper.java

/**
 * Creates a new temporary list of {@code Long} values. The created temporary list is
 * identified by the given ID. If a list has been created successfully, it will be filled
 * in by {@code Collection} of provided {@code Long} values.
 *
 * @param listId {@code Long} represents unique ID that is used to identify a temporary list
 * @param list   {@code Collection} specifies collection of {@code Long} values that should be
 *               associated with a temporary list if this call is succeeded
 * @return {@code Long} represents unique ID of a temporary list that has been created after
 * this call/* w w  w. j a va2s  .  c o  m*/
 * @throws IllegalArgumentException will be thrown if <tt>listId</tt> or <tt>list</tt> are
 *                                  <tt>null</tt>, or the given <tt>list</tt> is empty
 */
@Transactional(propagation = Propagation.MANDATORY)
public Long createTempLongList(final Long listId, final Collection<Long> list) {
    Assert.notNull(listId);
    Assert.isTrue(CollectionUtils.isNotEmpty(list));
    // creates a new local temporary table if it doesn't exists to handle temporary lists
    getJdbcTemplate().update(createTemporaryListQuery);
    // fills in a temporary list by given values
    int i = 0;
    final Iterator<Long> iterator = list.iterator();
    final MapSqlParameterSource[] batchArgs = new MapSqlParameterSource[list.size()];
    while (iterator.hasNext()) {
        MapSqlParameterSource params = new MapSqlParameterSource();
        params.addValue(HelperParameters.LIST_ID.name(), listId);
        params.addValue(HelperParameters.LIST_VALUE.name(), iterator.next());
        batchArgs[i] = params;
        i++;
    }
    getNamedParameterJdbcTemplate().batchUpdate(insertTemporaryListItemQuery, batchArgs);
    return listId;
}

From source file:se.inera.intyg.intygstjanst.web.service.impl.CertificateServiceImpl.java

@Override
@Transactional(propagation = Propagation.MANDATORY, noRollbackFor = { InvalidCertificateException.class,
        CertificateRevokedException.class })
public Certificate revokeCertificate(Personnummer civicRegistrationNumber, String certificateId,
        RevokeType revokeData) throws InvalidCertificateException, CertificateRevokedException {
    Certificate certificate = null;
    try {/*from w ww.  j av  a  2s . c  o m*/
        certificate = getCertificateInternal(civicRegistrationNumber, certificateId);
    } catch (PersistenceException e) {
        throw new InvalidCertificateException(certificateId, civicRegistrationNumber);
    }

    if (certificate == null) {
        throw new InvalidCertificateException(certificateId, civicRegistrationNumber);
    }

    if (certificate.isRevoked()) {
        throw new CertificateRevokedException(certificateId);
    }

    setCertificateState(civicRegistrationNumber, certificateId, HVTARGET, CertificateState.CANCELLED, null);

    if (revokeData != null) {
        sendRevokeMessagesToRecipients(certificate, revokeData);
    }

    return certificate;
}

From source file:com.epam.catgenome.dao.vcf.VcfFileDao.java

/**
 * Load sample metadata for multiple file IDs
 *
 * @param fileIds {@code List&lt;Long&gt;} of file IDs to load samples for
 * @return a map of {@code VcfFile} IDs to lists of their samples
 *//*from  w ww. j a va  2s . c o m*/
@Transactional(propagation = Propagation.MANDATORY)
public Map<Long, List<VcfSample>> loadSamplesByFileIds(Collection<Long> fileIds) {
    if (fileIds == null || fileIds.isEmpty()) {
        return Collections.emptyMap();
    }

    Map<Long, List<VcfSample>> map = new HashMap<>();

    long listId = daoHelper.createTempLongList(fileIds);

    getJdbcTemplate().query(loadSamplesByFileIdsQuery, rs -> {
        VcfSample sample = SampleParameters.getVcfSampleMapper().mapRow(rs, 0);
        long vcfId = rs.getLong(VcfParameters.VCF_ID.name());
        if (!map.containsKey(vcfId)) {
            map.put(vcfId, new ArrayList<>());
        }
        map.get(vcfId).add(sample);
    }, listId);

    daoHelper.clearTempList(listId);
    return map;
}

From source file:ru.org.linux.user.UserLogDao.java

@Transactional(rollbackFor = Exception.class, propagation = Propagation.MANDATORY)
public void unsetCorrector(@Nonnull User user, @Nonnull User moderator) {
    jdbcTemplate.update(/*from  w w  w . j  a va  2s . co  m*/
            "INSERT INTO user_log (userid, action_userid, action_date, action, info) VALUES (?,?,CURRENT_TIMESTAMP, ?::user_log_action, ?)",
            user.getId(), moderator.getId(), UserLogAction.UNSET_CORRECTOR.toString(), ImmutableMap.of());
}