下面列出了org.springframework.transaction.annotation.Propagation#SUPPORTS 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
@Transactional(propagation = Propagation.SUPPORTS, readOnly = false)
public boolean updateSystemCarAttr(DataCarAttribute DataCarAttribute) {
// 对图片的长度进行判断
String facadeImage = DataCarAttribute.getFacadeImage();
String centralImage = DataCarAttribute.getCentralImage();
String seatImage = DataCarAttribute.getSeatImage();
String detailImage = DataCarAttribute.getDetailImage();
if (facadeImage!=null && !"".equals(facadeImage)){
DataCarAttribute.setFacadeImageCount(facadeImage.split(",").length);
}
if (centralImage!=null && !"".equals(centralImage)){
DataCarAttribute.setCentralImageCount(centralImage.split(",").length);
}
if (seatImage!=null && !"".equals(seatImage)){
DataCarAttribute.setSeatImageCount(seatImage.split(",").length);
}
if (detailImage!=null && !"".equals(detailImage)){
DataCarAttribute.setDetailImageCount(detailImage.split(",").length);
}
return carAttributeDao.update(DataCarAttribute) > 0;
}
/**
* Returns a list of all users which are accessible by the current logged in user and not planned in the given HRViewData object.
* @return Result list (may be empty but never null).
*/
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public List<PFUserDO> getUnplannedResources(final HRViewData data)
{
final List<PFUserDO> users = new ArrayList<PFUserDO>();
final QueryFilter queryFilter = new QueryFilter(new BaseSearchFilter());
queryFilter.addOrder(Order.asc("firstname")).addOrder(Order.asc("lastname"));
final List<PFUserDO> allUsers = userDao.getList(queryFilter);
if (allUsers != null) {
for (final PFUserDO user : allUsers) {
final HRViewUserData userData = data.getUserData(user);
if (userData == null || NumberHelper.isNotZero(userData.getPlannedDaysSum()) == false) {
users.add(user);
}
}
}
return users;
}
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public Customer getCustomerById(final Integer customerId)
throws NoSuchCustomerException {
final Customer customer = getJpaTemplate().find(Customer.class,
customerId);
if (customer == null) {
NoSuchCustomer noSuchCustomer = new NoSuchCustomer();
noSuchCustomer.setCustomerId(customerId);
throw new NoSuchCustomerException(
"Did not find any matching customer for id [" + customerId
+ "].", noSuchCustomer);
} else {
return customer;
}
}
/**
* Gets the highest Auftragsnummer.
* @param auftrag wird benötigt, damit geschaut werden kann, ob dieser Auftrag ggf. schon existiert. Wenn er schon eine Nummer hatte, so
* kann verhindert werden, dass er eine nächst höhere Nummer bekommt. Ein solcher Auftrag bekommt die alte Nummer wieder
* zugeordnet.
*/
@SuppressWarnings("unchecked")
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public Integer getNextNumber(final AuftragDO auftrag)
{
if (auftrag.getId() != null) {
final AuftragDO orig = internalGetById(auftrag.getId());
if (orig.getNummer() != null) {
auftrag.setNummer(orig.getNummer());
return orig.getNummer();
}
}
final List<Integer> list = getSession().createQuery("select max(t.nummer) from AuftragDO t").list();
Validate.notNull(list);
if (list.size() == 0 || list.get(0) == null) {
log.info("First entry of AuftragDO");
return START_NUMBER;
}
Integer number = list.get(0);
return ++number;
}
@Transactional(propagation=Propagation.SUPPORTS)
public void satisfyDepend(LightweightDependency depend) {
/*
* Before setting the depend to in-active, obtain a list
* of frames and decrement the depend count on them.
*/
if (DependType.FRAME_BY_FRAME.equals(depend.type)) {
List<LightweightDependency> children =
dependDao.getChildDepends(depend);
for (LightweightDependency lwd: children) {
satisfyDepend(lwd);
}
return;
}
/*
* Only decrement the depend counts if the depend is
* actually set to inactive.
*/
if (dependDao.setInactive(depend)) {
logger.info("satisfied depend: " + depend.getId());
for (FrameInterface f: frameDao.getDependentFrames(depend)) {
if (!dependDao.decrementDependCount(f)) {
logger.warn("warning, depend count for " +
depend.getId() + "was not decremented " +
"for frame " + f + "because the count is " +
"already 0.");
}
}
}
}
@Override
@Transactional(propagation = Propagation.SUPPORTS)
public <T extends Serializable> List<T> findFrom(T entity) {
EntityMeta entityMeta = sqlToyLazyDao.getEntityMeta(entity.getClass());
if (StringUtil.isBlank(entityMeta.getListSql())) {
throw new DataAccessException(
"findFromByEntity[" + entity.getClass().getName() + "]沒有在类上用注解@ListSql()定义查询sql!");
}
return sqlToyLazyDao.findBySql(entityMeta.getListSql(), entity);
}
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public MonthlyEmployeeReport getReport(int year, int month, PFUserDO user)
{
if (user == null || year <= 0) {
return null;
}
MonthlyEmployeeReport report = new MonthlyEmployeeReport(year, month);
EmployeeDO employee = employeeDao.getByUserId(user.getId());
if (employee != null) {
report.setEmployee(employee);
} else {
report.setUser(user);
}
report.init();
TimesheetFilter filter = new TimesheetFilter();
filter.setDeleted(false);
filter.setStartTime(report.getFromDate());
filter.setStopTime(report.getToDate());
filter.setUserId(user.getId());
List<TimesheetDO> list = timesheetDao.getList(filter);
if (CollectionUtils.isNotEmpty(list) == true) {
for (TimesheetDO sheet : list) {
report.addTimesheet(sheet);
}
}
report.calculate();
return report;
}
@Override
@Transactional(propagation = Propagation.SUPPORTS)
public <T extends Serializable> PaginationModel<T> findPageFrom(PaginationModel paginationModel, T entity,
ReflectPropertyHandler reflectPropertyHandler) {
EntityMeta entityMeta = sqlToyLazyDao.getEntityMeta(entity.getClass());
if (StringUtil.isBlank(entityMeta.getPageSql())) {
throw new DataAccessException(
"findPageFromByEntity[" + entity.getClass().getName() + "]沒有在类上用注解@PaginationSql() 定义分页sql!");
}
return (PaginationModel<T>) sqlToyLazyDao.findPageByQuery(paginationModel,
new QueryExecutor(entityMeta.getPageSql(), entity).reflectPropertyHandler(reflectPropertyHandler))
.getPageResult();
}
@Override
@Transactional(propagation = Propagation.SUPPORTS)
public <T extends Serializable> List<T> findTopFrom(T entity, double topSize) {
EntityMeta entityMeta = sqlToyLazyDao.getEntityMeta(entity.getClass());
if (StringUtil.isBlank(entityMeta.getListSql())) {
throw new DataAccessException(
"findTopFromByEntity[" + entity.getClass().getName() + "]沒有在类上用注解@ListSql()定义查询sql!");
}
return (List<T>) sqlToyLazyDao.findTopBySql(entityMeta.getListSql(), entity, topSize);
}
@Transactional(propagation = Propagation.SUPPORTS)
public boolean hasAccessToDevice(UserVO user, String deviceId) {
if (!user.isAdmin()) {
long count = userDao.hasAccessToDevice(user, deviceId);
return count > 0;
}
return true;
}
@Transactional(propagation = Propagation.SUPPORTS)
public void runFilterOnGroup(FilterEntity filter, GroupInterface group) {
for (JobDetail job: jobDao.findJobs(group)) {
if (match(filter,job)) {
applyActions(filter,job);
}
}
}
/** Layer Depends **/
@Override
@Transactional(propagation=Propagation.SUPPORTS)
public void createDepend(LayerOnJob depend) {
if (jobDao.isJobComplete(depend.getDependOnJob())) {
throw new DependException(
"The job you are depending on is already complete.");
}
dependDao.insertDepend(depend);
updateDependCount(depend.getDependErLayer());
}
@Override
@Transactional(propagation=Propagation.SUPPORTS)
public void createDepend(FrameOnFrame depend) {
if (frameDao.isFrameComplete(depend.getDependOnFrame())) {
depend.setActive(false);
}
dependDao.insertDepend(depend);
if (depend.isActive()) {
updateDependCounts(depend.getDependErFrame());
}
}
@Override
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public List<TaskDO> getList(final BaseSearchFilter filter) throws AccessException
{
final TaskFilter myFilter;
if (filter instanceof TaskFilter) {
myFilter = (TaskFilter) filter;
} else {
myFilter = new TaskFilter(filter);
}
final QueryFilter queryFilter = new QueryFilter(myFilter);
final Collection<TaskStatus> col = new ArrayList<TaskStatus>(4);
if (myFilter.isNotOpened() == true) {
col.add(TaskStatus.N);
}
if (myFilter.isOpened() == true) {
col.add(TaskStatus.O);
}
if (myFilter.isClosed() == true) {
col.add(TaskStatus.C);
}
if (col.size() > 0) {
queryFilter.add(Restrictions.in("status", col));
} else {
// Note: Result set should be empty, because every task should has one of the following status values.
queryFilter.add(Restrictions.not(Restrictions.in("status", new TaskStatus[] { TaskStatus.N, TaskStatus.O, TaskStatus.C})));
}
queryFilter.addOrder(Order.asc("title"));
if (log.isDebugEnabled() == true) {
log.debug(myFilter.toString());
}
return getList(queryFilter);
}
@Transactional(propagation = Propagation.SUPPORTS)
public void runFilterOnJob(FilterEntity filter, String id) {
JobDetail j = jobDao.getJobDetail(id);
if (match(filter, j)) {
applyActions(filter,j);
}
}
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public BigDecimal getBalance(Long id) {
return repository.getAccount(id).getBalance();
}
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public <T extends Serializable> T find(Class<T> entityClass, Object primaryKey) {
return em.find(entityClass, primaryKey);
}
@Override
@Transactional(propagation = Propagation.SUPPORTS)
public void addSupports(User2 user){
user2Mapper.insert(user);
}
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
@Override
public AuthenticateResponse refresh(String accessToken, String clientToken) throws ForbiddenOperationException {
return selectProfile(accessToken, clientToken, null);
}
@Override
@Transactional(propagation = Propagation.SUPPORTS)
public void addSupports(User1 user){
user1Mapper.insert(user);
}