Java Code Examples for org.springframework.transaction.annotation.Propagation#MANDATORY

The following examples show how to use org.springframework.transaction.annotation.Propagation#MANDATORY . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: tutorial   File: PersonService.java    License: MIT License 5 votes vote down vote up
/**
 * Propagation.MANDATORY 必须在一个已有的事务中执行,否则抛出异常
 */
@Transactional(propagation=Propagation.MANDATORY)
public void insertMandatory(PersonDto person, boolean throwException) {
    personDao.insert(person);
    if(throwException) {
        throw new RuntimeException("ERROR");
    }
}
 
Example 2
Source Project: transaction-test   File: User2ServiceImpl.java    License: MIT License 4 votes vote down vote up
@Override
@Transactional(propagation = Propagation.MANDATORY)
public void addMandatory(User2 user){
	user2Mapper.insert(user);
}
 
Example 3
Source Project: transaction-test   File: User2ServiceImpl.java    License: MIT License 4 votes vote down vote up
@Override
@Transactional(propagation = Propagation.MANDATORY)
public void addMandatoryException(User2 user){
	user2Mapper.insert(user);
	throw new RuntimeException();
}
 
Example 4
Source Project: transaction-test   File: User1ServiceImpl.java    License: MIT License 4 votes vote down vote up
@Override
@Transactional(propagation = Propagation.MANDATORY)
public void addMandatory(User1 user){
	user1Mapper.insert(user);
}
 
Example 5
Source Project: transaction-test   File: User1ServiceImpl.java    License: MIT License 4 votes vote down vote up
@Override
@Transactional(propagation = Propagation.MANDATORY)
public void addMandatoryException(User1 user){
	user1Mapper.insert(user);
	throw new RuntimeException();
}
 
Example 6
Source Project: transaction-test   File: User2ServiceImpl.java    License: MIT License 4 votes vote down vote up
@Override
@Transactional(propagation = Propagation.MANDATORY)
public void addMandatory(User2 user){
	user2Mapper.insert(user);
}
 
Example 7
Source Project: transaction-test   File: User2ServiceImpl.java    License: MIT License 4 votes vote down vote up
@Override
@Transactional(propagation = Propagation.MANDATORY)
public void addMandatoryException(User2 user){
	user2Mapper.insert(user);
	throw new RuntimeException();
}
 
Example 8
Source Project: transaction-test   File: User1ServiceImpl.java    License: MIT License 4 votes vote down vote up
@Override
@Transactional(propagation = Propagation.MANDATORY)
public void addMandatory(User1 user){
	user1Mapper.insert(user);
}
 
Example 9
Source Project: transaction-test   File: User1ServiceImpl.java    License: MIT License 4 votes vote down vote up
@Override
@Transactional(propagation = Propagation.MANDATORY)
public void addMandatoryException(User1 user){
	user1Mapper.insert(user);
	throw new RuntimeException();
}
 
Example 10
@Transactional(propagation = Propagation.MANDATORY, readOnly = true)
public User findByUserIdWithPropagationMandatory(Integer id) {
    return userRepository.findById(id);
}
 
Example 11
Source Project: training   File: TransactionUtilImpl.java    License: MIT License 4 votes vote down vote up
@Override
@Transactional(propagation = Propagation.MANDATORY)
public void executeWith_MANDATORY(Runnable runnable) {
	runnable.run();
}
 
Example 12
Source Project: training   File: TransactionUtilImpl.java    License: MIT License 4 votes vote down vote up
@Override
@Transactional(propagation = Propagation.MANDATORY)
public void executeWith_MANDATORY(Runnable runnable) {
	runnable.run();
}
 
Example 13
/**
 * @param cache Cache.
 */
@Transactional(propagation = Propagation.MANDATORY)
public void putWithMandatoryPropagation(IgniteCache<Integer, String> cache) {
    cache.put(1, "1");
}
 
Example 14
@Transactional(propagation = Propagation.MANDATORY, readOnly = true)
public User findByUserIdWithPropagationMandatory(Integer id) {
    return userRepository.findById(id);
}
 
Example 15
Source Project: tutorials   File: FooTransactionalUnitTest.java    License: MIT License 4 votes vote down vote up
@Override
@Transactional(propagation = Propagation.MANDATORY)
public Foo create(Foo entity) {
    return super.create(entity);
}
 
Example 16
Source Project: tutorials   File: FooTransactionalUnitTest.java    License: MIT License 4 votes vote down vote up
@Transactional(propagation = Propagation.MANDATORY)
public Foo identity(Foo entity) {
    return entity;
}
 
Example 17
@Transactional(propagation = Propagation.MANDATORY)
public <T extends Serializable> void persist( T entity ){
    em.persist(entity);
}
 
Example 18
@Transactional(propagation = Propagation.MANDATORY)
public <T extends Serializable> T merge(T entity) {
    return em.merge(entity);
}
 
Example 19
@Transactional(propagation = Propagation.MANDATORY)
public <T extends Serializable> void remove(T entity) {
    em.remove(entity);
}
 
Example 20
@Transactional(propagation = Propagation.MANDATORY)
public long count(CriteriaQuery<Long> cq) {
    return em.createQuery(cq).getSingleResult();
}