@Service
public class VersionServiceImpl implements VersionServiceI {
@Autowired
VersionMapper versionMapper;
@Override
public Version selectByPrimaryKey(String type) {
Version version = versionMapper.selectByPrimaryKey(type);
return version;
}
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class)
@Override
public int updateByPrimaryKeySelective(Version record) {
int i = versionMapper.updateByPrimaryKeySelective(record);
return i;
}
@Override
public String getMsgId() {
int msgId = versionMapper.getMsgId();
return String.format("%06d", msgId);
}
}
spring的@Transactional是基于bean的aop的,要用其他bean比如controller调用@Transactional的service方法,异常类型要是RuntimeExceiton才能,否则要@Transactional(rollbackFor=Exception.class)