本文整理汇总了Java中org.springframework.transaction.annotation.Propagation.MANDATORY属性的典型用法代码示例。如果您正苦于以下问题:Java Propagation.MANDATORY属性的具体用法?Java Propagation.MANDATORY怎么用?Java Propagation.MANDATORY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.springframework.transaction.annotation.Propagation
的用法示例。
在下文中一共展示了Propagation.MANDATORY属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAttachmentsForItemIds
@Override
@Transactional(propagation = Propagation.MANDATORY)
public ListMultimap<Long, Attachment> getAttachmentsForItemIds(Collection<Long> ids)
{
if( ids.isEmpty() )
{
return ImmutableListMultimap.of();
}
List<Object[]> attachments = getHibernateTemplate().findByNamedParam(
"select a, i.id from Item i join i.attachments a where i.id in (:items) order by index(a) ASC", "items",
ids);
ListMultimap<Long, Attachment> multiMap = ArrayListMultimap.create();
for( Object[] attachmentRow : attachments )
{
multiMap.put((Long) attachmentRow[1], (Attachment) attachmentRow[0]);
}
return multiMap;
}
示例2: deleteForTaxonomy
@Override
@Transactional(propagation = Propagation.MANDATORY)
public void deleteForTaxonomy(final Taxonomy taxonomy)
{
getHibernateTemplate().execute(new HibernateCallback()
{
@Override
public Object doInHibernate(Session session)
{
Query query = session
.createQuery("delete from TermAttributes ta where ta.term.id in (from Term where taxonomy = :taxonomy)");
query.setParameter("taxonomy", taxonomy);
query.executeUpdate();
query = session.createQuery("delete from Term where taxonomy = :taxonomy");
query.setParameter("taxonomy", taxonomy);
query.executeUpdate();
return null;
}
});
}
示例3: afterFinishedEditing
@Transactional(propagation = Propagation.MANDATORY)
@Override
protected void afterFinishedEditing()
{
super.afterFinishedEditing();
// Refresh item name and description if either of the XPaths has changed
if( editing && refreshSchemaItems )
{
publishEventAfterCommit(new ItemOperationEvent(
new FactoryMethodLocator<BaseFilter>(FilterFactory.class, "refreshSchemaItems", entity.getId())));
return;
}
// Re-index items if the indexing settings for schema nodes has changed
if( editing && reindexItems )
{
publishEvent(new ItemReindexEvent(new SchemaFilter(entity)));
return;
}
}
示例4: deleteUnindexed
@Override
@Transactional(propagation = Propagation.MANDATORY)
public int deleteUnindexed(final String user, final Collection<String> reasons, final String attemptId)
{
if( reasons.isEmpty() )
{
return 0;
}
return (Integer) getHibernateTemplate().execute(new HibernateCallback()
{
@Override
public Object doInHibernate(Session session)
{
Query query = session.createQuery(
"delete from Notification " + "where institution = :inst and userTo = :user and processed = false "
+ "and reason in (:reasons) and attemptId = :attempt");
query.setParameter(ATTEMPT, attemptId);
query.setParameterList(REASONS, reasons);
query.setParameter(USER, user);
query.setParameter(INST, CurrentInstitution.get());
return query.executeUpdate();
}
});
}
示例5: loadSamplesByFileIds
/**
* Load sample metadata for multiple file IDs
*
* @param fileIds {@code List<Long>} of file IDs to load samples for
* @return a map of {@code VcfFile} IDs to lists of their samples
*/
@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;
}
示例6: createTempList
@Transactional(propagation = Propagation.MANDATORY)
public Long createTempList(final Long listId, final Collection<? extends BaseEntity> 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<? extends BaseEntity> 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().getId());
batchArgs[i] = params;
i++;
}
getNamedParameterJdbcTemplate().batchUpdate(insertTemporaryListItemQuery, batchArgs);
return listId;
}
示例7: insertNewTerm
@Override
@Transactional(propagation = Propagation.MANDATORY)
public Term insertNewTerm(Taxonomy taxonomy, Term parent, String termValue, int index)
{
termValue = termValue.trim();
checkTermValue(termValue, taxonomy, parent);
final int left = parent != null ? getLeftForChildIndex(parent, index)
: getLeftForRootTermIndex(taxonomy, index);
incrementLaR(null, taxonomy, left, Integer.MAX_VALUE, 2);
final String fullValue = parent == null ? termValue : parent.getFullValue() + TaxonomyConstants.TERM_SEPARATOR
+ termValue;
final Term newChild = new Term();
newChild.setUuid(UUID.randomUUID().toString());
newChild.setValue(termValue);
newChild.setLeft(left);
newChild.setRight(left + 1);
newChild.setParent(parent);
newChild.setTaxonomy(taxonomy);
newChild.setFullValue(fullValue);
save(newChild);
return newChild;
}
示例8: loadBucketById
/**
* Loads a persisted {@code Bucket} record, specified by it's ID
* @param bucketId a Bucket ID
* @return {@code Bucket} instance
*/
@Transactional(propagation = Propagation.MANDATORY)
public Bucket loadBucketById(final Long bucketId) {
List<Bucket> buckets = getJdbcTemplate().query(loadBucketByIdQuery, BucketParameters.getPasswordRowMapper(),
bucketId);
return buckets.isEmpty() ? null : buckets.get(0);
}
示例9: createSegFile
/**
* Persists {@code SegFile} record to the database
* @param segFile a {@code SegFile} instance to be persisted
* @param realId SegFile's real ID, generated with SegFileDao::createGeneFileId() method
*/
@Transactional(propagation = Propagation.MANDATORY)
public void createSegFile(SegFile segFile, long realId) {
segFile.setBioDataItemId(segFile.getId());
segFile.setId(realId);
getNamedParameterJdbcTemplate().update(createSegFileQuery, BiologicalDataItemDao.FeatureFileParameters
.getLinkedTableParameters(SegParameters.SEG_ID.name(), segFile));
}
示例10: findTasksForUser
@SuppressWarnings("unchecked")
@Override
@Transactional(propagation = Propagation.MANDATORY)
public Collection<WorkflowItem> findTasksForUser(String userId)
{
return getHibernateTemplate().findByNamedParam(
"from WorkflowItem i join i.users as u where u = :userID and i.workflow.institution = :inst",
new String[]{"userID", "inst"}, new Object[]{userId, CurrentInstitution.get()});
}
示例11: deleteAll
@Transactional(propagation = Propagation.MANDATORY)
@Override
public void deleteAll()
{
for( QtiAssessmentResult result : listAll() )
{
delete(result);
flush();
clear();
}
}
示例12: saveBookmark
/**
* Saves a database entity to a database. To perform a {@code Bookmark} update, an ID should be set.
* @param bookmark a {@code Bookmark} to save
*/
@Transactional(propagation = Propagation.MANDATORY)
public void saveBookmark(Bookmark bookmark) {
if (bookmark.getId() == null) {
bookmark.setId(daoHelper.createId(bookmarkSequenceName));
getNamedParameterJdbcTemplate().update(insertBookmarkQuery, BookmarkParameters.getParameters(bookmark));
} else {
getNamedParameterJdbcTemplate().update(updateBookmarkQuery, BookmarkParameters.getParameters(bookmark));
}
}
示例13: saveHolding
@Override
@Transactional(propagation = Propagation.MANDATORY)
public long saveHolding(Item item, H holding)
{
holding.setItem(item);
return save(holding);
}
示例14: deleteAllForItem
@Override
@Transactional(propagation = Propagation.MANDATORY)
public void deleteAllForItem(ItemId itemId)
{
getHibernateTemplate().bulkUpdate("delete from Notification where institution = ? and itemidOnly = ?",
new Object[]{CurrentInstitution.get(), itemId.toString()});
}
示例15: getNotificationsForItem
@SuppressWarnings("unchecked")
@Override
@Transactional(propagation = Propagation.MANDATORY)
public List<Notification> getNotificationsForItem(ItemId itemId, Institution institution)
{
List<Notification> notifications = getHibernateTemplate().findByNamedParam(
"from Notification where itemidOnly = :itemid and institution = :inst", new String[]{ITEMID, INST},
new Object[]{itemId.toString(), institution});
return notifications;
}