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:com.epam.catgenome.dao.gene.GeneFileDao.java

/**
 * Creates a new ID for a {@code GeneFile} instance
 * @return {@code Long} new {@code GeneFile} ID
 *//*from  w w  w .ja va 2 s  . c o  m*/
@Transactional(propagation = Propagation.MANDATORY)
public Long createGeneFileId() {
    return daoHelper.createId(geneFileSequenceName);
}

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

/**
 * Loads {@code VcfFile} records, saved for a specific reference ID. <br>
 *
 * @param referenceId {@code long} a reference ID in the system
 * @return {@code List&lt;VcfFile&gt;} instance
 *///ww  w . j a v a2  s  .  com
@Transactional(propagation = Propagation.MANDATORY)
public List<VcfFile> loadVcfFilesByReferenceId(long referenceId) {
    return getJdbcTemplate()
            .query(loadVcfFilesByReferenceIdQuery,
                    BiologicalDataItemDao.BiologicalDataItemParameters.getRowMapper(), referenceId)
            .stream().map(f -> (VcfFile) f).collect(Collectors.toList());
}

From source file:com.jaspersoft.jasperserver.api.metadata.data.snapshot.hibernate.HibernateDataSnapshotContentsService.java

@Transactional(propagation = Propagation.MANDATORY, readOnly = false)
public long saveDataSnapshot(ExecutionContext context, final DataSnapshot snapshot) {
    if (log.isDebugEnabled()) {
        log.debug("saving snapshot");
    }/*from w ww  .jav  a 2s  .  c om*/

    DataContainer dataContainer = new FileBufferedDataContainer();
    try {
        boolean closeOut = true;
        OutputStream out = dataContainer.getOutputStream();
        try {
            // write the snapshot to a temporary location
            getSnapshotSerializer().writeSnapshot(snapshot, out);
            closeOut = false;
            out.close();
        } catch (IOException e) {
            throw new JSExceptionWrapper("Failed to serialize data snapshot", e);
        } finally {
            if (closeOut) {
                try {
                    out.close();
                } catch (IOException e) {
                    log.warn("Failed to close data container stream for data snapshot");
                }
            }
        }

        return saveSnapshotData(dataContainer);
    } finally {
        dataContainer.dispose();
    }
}

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

/**
 * Persists a {@code Reference} entity in database with a specified ID
 * @param reference to persist/*from   ww w .  j av a 2 s . c  om*/
 * @param referenceId ID for the reference
 * @return saved {@code Reference} instance
 */
@Transactional(propagation = Propagation.MANDATORY)
public Reference createReferenceGenome(final Reference reference, final long referenceId) {

    reference.setBioDataItemId(reference.getId());
    reference.setId(referenceId);

    final MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue(GenomeParameters.REFERENCE_GENOME_ID.name(), reference.getId());
    params.addValue(GenomeParameters.BIO_DATA_ITEM_ID.name(), reference.getBioDataItemId());
    params.addValue(GenomeParameters.SIZE.name(), reference.getSize());
    params.addValue(GenomeParameters.INDEX_ID.name(), reference.getIndex().getId());
    params.addValue(GenomeParameters.GENE_ITEM_ID.name(),
            reference.getGeneFile() != null ? reference.getGeneFile().getId() : null);

    getNamedParameterJdbcTemplate().update(createReferenceGenomeQuery, params);
    return reference;
}

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

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

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

/**
 * Loads a List of BiologicalDataItem from the database by their IDs
 * @param ids List of IDs of BiologicalDataItem instances
 * @return List of BiologicalDataItem, matching specified IDs
 *//*from   ww w .j ava 2 s . co m*/
@Transactional(propagation = Propagation.MANDATORY)
public List<BiologicalDataItem> loadBiologicalDataItemsByIds(List<Long> ids) {
    if (ids == null || ids.isEmpty()) {
        return Collections.emptyList();
    }

    Long listId = daoHelper.createTempLongList(ids);

    final MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue(BiologicalDataItemParameters.BIO_DATA_ITEM_ID.name(), listId);

    List<BiologicalDataItem> items = getNamedParameterJdbcTemplate().query(loadBiologicalDataItemsByIdsQuery,
            params, getRowMapper());

    daoHelper.clearTempList(listId);

    return items;
}

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

/**
 * Creates a new ID for a {@code VcfFile} instance
 *
 * @return {@code Long} new {@code VcfFile} ID
 */// ww  w.java  2s. c o  m
@Transactional(propagation = Propagation.MANDATORY)
public Long createVcfFileId() {
    return daoHelper.createId(vcfFileSequenceName);
}

From source file:com.oak_yoga_studio.dao.impl.EnrollmentDAOImpl.java

@Transactional(propagation = Propagation.MANDATORY)
@Override/*from  ww w.j  a v a 2 s  . c  o  m*/
public void changeEnrollmentStatus(String status) {

    // ??add enrollment parama
    //should do setEnrollmentStatus(status)
    // and update Enrollment
}

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

/**
 * Creates a new temporary list of {@code Long} values and generates unique ID for a
 * created temporary list.//  w  w w .j a  v a 2s . c  om
 *
 * @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
 * @throws IllegalArgumentException will be thrown if the given <tt>list</tt> is empty
 */
@Transactional(propagation = Propagation.MANDATORY)
public Long createTempLongList(final Collection<Long> list) {
    Assert.isTrue(CollectionUtils.isNotEmpty(list));
    return createTempLongList(createListId(), list);
}

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

@Transactional(rollbackFor = Exception.class, propagation = Propagation.MANDATORY)
public void logSetPassword(@Nonnull User user) {
    jdbcTemplate.update(/*www  .  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, ?)",
            user.getId(), user.getId(), UserLogAction.SET_PASSWORD.toString(), ImmutableMap.of());
}