开发者社区> 问答> 正文

java 报错:javax.transaction.rollbackexcept?报错

后台代码如下:

public List<Project> findAllActivitiesByDay()
{
 Set<User> useres=userDAO.findUserByEnabled(true);
List<Project> list3 = new ArrayList<Project>();
Calendar time=Calendar.getInstance();
int month=time.get(Calendar.MONTH);
int year=time.get(Calendar.YEAR);
int day=time.get(Calendar.DAY_OF_MONTH);
for(int i=day;i>0;i--){
Project project2=new Project();
project2.setCreateDate(Calendar.getInstance());
project2.getCreateDate().set(year, month, i, 0, 0, 0);
Calendar atime=project2.getCreateDate();
Set<Activity> acts=project2.getActivities();
Set<Task> tasks=project2.getTasks();
Set<ProjectFinance>  finances=project2.getProjectFinances();
List<User> users=new ArrayList<User>();
 users.addAll(useres);
for(User user:users){
int id=user.getId();
StringBuffer sb = new StringBuffer("select a from Activity a where 1=1 and a.activityTime='"+atime+"' and a.userByCreater.id='"+id+"'");
   List<Activity> activitys=activityDAO.executeQuery(sb.toString());
   if(activitys.size()>0){
    Activity activity=activitys.get(0);
    Calendar actTime=activity.getActivityTime();
    Calendar createTime=activity.getCreatedDate();
    int actDay=actTime.get(Calendar.DAY_OF_MONTH);
    int createDay=createTime.get(Calendar.DAY_OF_MONTH);
    int createHour=createTime.get(Calendar.HOUR);
    if(actDay==createDay){
    acts.add(activity);
    }else{
    if(actDay+2>createDay&&createHour<11)
    {
    acts.add(activity);
    }
    else{
    Task task=new Task();
    task.setUserByResponser(user);
    tasks.add(task);
    }
    }
   }else{
    ProjectFinance finance=new ProjectFinance();
  finance.setUserByCreater(user);
  finances.add(finance);
   }
}
list3.add(project2);
}
return list3;
}

报如下错误:
javax.transaction.RollbackException: Transaction set to rollback only
at com.atomikos.icatch.jta.TransactionImp.commit(TransactionImp.java:312)
at com.atomikos.icatch.jta.TransactionManagerImp.commit(TransactionManagerImp.java:612)
at com.atomikos.icatch.jta.UserTransactionImp.commit(UserTransactionImp.java:168)
at org.springframework.transaction.jta.JtaTransactionManager.doCommit(JtaTransactionManager.java:1010)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:393)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy59.findAllActivitiesByDay(Unknown Source)

展开
收起
爱吃鱼的程序员 2020-06-22 21:01:24 577 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    今天我也遇见这样的问题,楼主解决了吗

     

    没有没有
    2020-06-22 21:01:41
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
Spring Cloud Alibaba - 重新定义 Java Cloud-Native 立即下载
The Reactive Cloud Native Arch 立即下载
JAVA开发手册1.5.0 立即下载